Fw: How can I convert a date to a string version of itself?

classic Classic list List threaded Threaded
1 message Options
Reply | Threaded
Open this post in threaded view
|

Fw: How can I convert a date to a string version of itself?

Martha Hewett
Ah - the light dawns.  I'm doing this with the GUI and forgot to declare the target variable a string.  Dumb.  Thanks for the help.  It's done now.
Martha Hewett
Director of Research | 612.335.5865
Center for Energy and Environment
212 Third Avenue North, Suite 560 | Minneapolis, MN 55401





From:        David Marso <[hidden email]>
To:        [hidden email]
Date:        11/22/2011 04:26 PM
Subject:        Re: How can I convert a date to a string version of itself?
Sent by:        "SPSSX(r) Discussion" <[hidden email]>




LOOK at the SUBSTR, CONCAT, STRING functions!

DATA LIST / ID DATE (F4,X,DATE11).
BEGIN DATA
1234 11-Feb-2009
END DATA.
LIST.

STRING NewID(A16).
STRING #TMP (A11).
COMPUTE #TMP=STRING(DATE,DATE11).
COMPUTE
NewID=CONCAT(STRING(ID,N4),"_",SUBSTR(#TMP,4,3),"_",SUBSTR(#TMP,1,2),"_",SUBSTR(#TMP,8)).
LIST.

 ID        DATE NEWID

1234 11-FEB-2009 1234_FEB_11_2009




Martha Hewett wrote
>
> I have a variable for site ID, and another variable for date.  Each site
> and date then has a bunch of records associated with it.  I want to create
> a variable that will be an identifier for each site visit, e.g. a
> particular value of that variable might be 1027_Feb_11_2009 for site 1027,
> the visit of Feb 11, 2009.  This is probably obvious but my attempts have
> not been working.
>
>
> Martha Hewett
> Director of Research | 612.335.5865
> Center for Energy and Environment
> 212 Third Avenue North, Suite 560 | Minneapolis, MN 55401
>


--
View this message in context:
http://spssx-discussion.1045642.n5.nabble.com/How-can-I-convert-a-date-to-a-string-version-of-itself-tp5014867p5014979.html
Sent from the SPSSX Discussion mailing list archive at Nabble.com.

=====================
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