Date: Wed, 23 Mar 2005 13:16:37 -0300
Reply-To: Hector Maletta <hmaletta@fibertel.com.ar>
Sender: "SPSSX(r) Discussion" <SPSSX-L@LISTSERV.UGA.EDU>
From: Hector Maletta <hmaletta@fibertel.com.ar>
Subject: Re: string to number
In-Reply-To: <5BE841EFFAB9664A9E057D5217856A6B315F60@bubsex02.cen.csin.cz>
Content-Type: text/plain; charset="us-ascii"
However, I don't see why the RECODE solution is not acceptable, especially
because you can recode all the variables at one stroke, as in:
RECODE oldvariablelist (CONVERT) into newvariablelist.
If you choose your new variable names wisely you may not need to rename them
back to the original variables' names. However, renaming is instantaneous
and does not require a data pass, and so is DELETE VARIABLES. In older
versions you delete variables through the /DROP or /KEEP subcommands in
MATCH FILES or SAVE, which do require a data pass, but it is the same data
pass used by the RECODE command, so no time is lost in that task (except the
data pass may be a bit slower with more tasks to perform during the pass).
Hector
> -----Original Message-----
> From: SPSSX(r) Discussion [mailto:SPSSX-L@LISTSERV.UGA.EDU]
> On Behalf Of Spousta Jan
> Sent: Wednesday, March 23, 2005 12:45 PM
> To: SPSSX-L@LISTSERV.UGA.EDU
> Subject: Re: string to number
>
>
> Hi,
>
> In the Variable View of the data editor, copy the word
> Numeric (Ctrl-C) in the Type column and paste it into the
> string columns (Ctrl-V) - it will convert them.
>
> Or write a macro if the syntax solution is needed.
>
> HTH
>
> Jan
>
> -----Original Message-----
> From: SPSSX(r) Discussion [mailto:SPSSX-L@LISTSERV.UGA.EDU]On
> Behalf Of Benny Kong
> Sent: Wednesday, March 23, 2005 4:42 PM
> To: SPSSX-L@LISTSERV.UGA.EDU
> Subject: string to number
>
>
> Hi,
>
> I need to change a bunch of variables from string to numberic values.
>
> For example,
>
> Var1 (A1)
> 0
> 1
> 0
> 1
>
> To,
>
> Var1 (F1)
> 0
> 1
> 0
> 1
>
>
>
> NUMBER function or RECODE is handy. However, I can only think
> of something as follows,
>
> recode var1 (convert) into var2.
> delete var1.
> rename var2 = var1.
> exe.
>
> The codes above seem not that efficient. I was wondering if I
> could do something directly (without creating an intermediate
> variable).
>
> Thank you guys very much in advance.
>
> Benny
>
|