|
----- Forwarded by Thara Vardhan/2003642/Staff/NSWPolice on 19/03/2008
17:13 ----- Thara Vardhan/2003642/Staff/NSWPolice 19/03/2008 17:12 To [hidden email]. cc Subject Thank you - help with extracting month as a numeric from a string variable Hi Richard Thanks a lot for helping me with a simpler way of writing syntax to extract month as a numeric from a string variable. Once again I want to convey my heartfelt thanks to Jon Peck and Richard Ristow for their prompt help and guidance. Every time I have needed some help in either solving a syntax problem or trying to find the best method of analysing data I have found the list members to be extremely helpful, knowledgeable with fantastic expertise in statistics & syntax programming. I must admit that I closely follow most discussions and am also saving a few imp ones in my personal folder- although I am not able to do it consistently given the work deadlines and priorities. For the benefit of all members I am positing the 2 methods that can be used to solve the problem The Problem: Currently I have a string variable "month" with values as Month 2007-01 2007-06 2007-12 I need to extract only the month values and compute a new variable as a numeric newmonth 01 06 12 Solution1: First option under the wizard is create a tome/date variable from a string variable * Date and Time Wizard: month1. COMPUTE month1 = number(Month, JDATE7). VARIABLE LABEL month1. VARIABLE LEVEL month1 (SCALE). FORMATS month1 (JDATE7). VARIABLE WIDTH month1(7). EXECUTE. extract part of adate or time variabe * Date and Time Wizard: finalmonth. COMPUTE finalmonth = XDATE.MDAY(month1). VARIABLE LABEL finalmonth "finalmonth". VARIABLE LEVEL finalmonth (SCALE). FORMATS finalmonth (F8.0). VARIABLE WIDTH finalmonth(8). EXECUTE. Solution2: NUMERIC newmonth2(N2). compute newmonth2=NUMBER(substr(month,6,8),F2). regards Thara Vardhan Senior Statistician Planning & Results Organisation Review and Support NSW Police Tel: (02) 8835-8526 _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ This message and any attachment is confidential and may be privileged or otherwise protected from disclosure. If you have received it by mistake, please let us know by reply and then delete it from your system; you should not copy the message or disclose its contents to anyone. ===================== To manage your subscription to SPSSX-L, send a message to [hidden email] (not to SPSSX-L), with no body text except the command. To leave the list, send the command SIGNOFF SPSSX-L For a list of commands to manage subscriptions, send the command INFO REFCARD |
| Free forum by Nabble | Edit this page |
