« Return to Thread: What exactly is 'width' in variable view?

Re: Compute newvar string+number

by Parise, Carol A. :: Rate this Message:

Reply to Author | View in Thread

worked perfectly. thanks a bunch.

-----Original Message-----
From: SPSSX(r) Discussion [mailto:SPSSX-L@...] On Behalf Of
Daniel Robertson
Sent: Thursday, July 02, 2009 11:29 AM
To: SPSSX-L@...
Subject: Re: Compute newvar string+number

You can use the string() function inside the concat() to convert the
value of Year to a string for the purposes of the transformation. You
may also want to use rtrim() on the V1 variable to remove trailing
blanks as necessary, e.g.,

string newvar (a8).
compute newvar = concat(rtrim(V1),string(Year,N4)).



Parise, Carol A. wrote:

> Hi all,
>
> I need to compute a new variable that combines a string variable with
> a year variable which is stored as a number.
>
> For example:
> V1      Year
> A5      2007
> C90     2006
>
> I would like my new variable to be a string:
>
> A52007
> C902006
>
> Should i just convert my year to a string and use concat to do this or

> does someone know of a trick so that i can leave year as a number?
>
> Thanks
> Carol
>
> =====================
> To manage your subscription to SPSSX-L, send a message to
> LISTSERV@... (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
>
>

--
Daniel Robertson
Senior Research and Planning Associate
Institutional Research and Planning
Cornell University / irp.cornell.edu

=====================
To manage your subscription to SPSSX-L, send a message to
LISTSERV@... (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

=====================
To manage your subscription to SPSSX-L, send a message to
LISTSERV@... (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

 « Return to Thread: What exactly is 'width' in variable view?