Convert Numeric Variables to String Variables

classic Classic list List threaded Threaded
3 messages Options
Reply | Threaded
Open this post in threaded view
|

Convert Numeric Variables to String Variables

Jim Moffitt
I want to convert three numeric variables into three new string
variables.
 
Here's the code I wrote along with a sample data set.
 
data list list (",") / id part 1 part 2 part3.
begin data
101,1256489784,1654879525,1598648959
102,4567891285,5689745827,9657849516
103,5784896547,6549784562,7896548954
end data.
 
*The next three lines are intended to create the string variables.
 
string spart1 (A10).
string spart2 (A10).
string spart3 (A10).
 
*And the next three lines are intended to deposit the values in the
numeric variables in the string variables.
 
recode part1 into spart1.
recode part2 into spart2.
recode part3 into spart3.
 
When I run the code I get the following error message after the first
recode line.
 
>Error # 4631 in column 14. Text: into

>On the RECODE command, the list of variables to be recoded includes the

>name of a nonexistent variable.

>This command not executed.

Any suggestions would be appreciated.

 
 
Reply | Threaded
Open this post in threaded view
|

Re: Convert Numeric Variables to String Variables

Edward Boadi
This works :

data list list (",") / id part1 part2 part3.
begin data
101,1256489784,1654879525,1598648959
102,4567891285,5689745827,9657849516
103,5784896547,6549784562,7896548954
end data.


string spart1 (A11).
string spart2 (A11).
string spart3 (A11).


COMPUTE      spart1   = string(part1,F10).
COMPUTE      spart2  = string(part2,F10) .
COMPUTE      spart3  = string(part3,F10) .
EXECUTE.



------Edward


-----Original Message-----
From: SPSSX(r) Discussion [mailto:[hidden email]]On Behalf Of
Jim Moffitt
Sent: Wednesday, July 19, 2006 3:09 PM
To: [hidden email]
Subject: Convert Numeric Variables to String Variables


I want to convert three numeric variables into three new string
variables.

Here's the code I wrote along with a sample data set.

data list list (",") / id part 1 part 2 part3.
begin data
101,1256489784,1654879525,1598648959
102,4567891285,5689745827,9657849516
103,5784896547,6549784562,7896548954
end data.

*The next three lines are intended to create the string variables.

string spart1 (A10).
string spart2 (A10).
string spart3 (A10).

*And the next three lines are intended to deposit the values in the
numeric variables in the string variables.

recode part1 into spart1.
recode part2 into spart2.
recode part3 into spart3.

When I run the code I get the following error message after the first
recode line.

>Error # 4631 in column 14. Text: into

>On the RECODE command, the list of variables to be recoded includes the

>name of a nonexistent variable.

>This command not executed.

Any suggestions would be appreciated.
Reply | Threaded
Open this post in threaded view
|

Re: Convert Numeric Variables to String Variables (Solved)

Jim Moffitt
 Thanks, Edward. This is just what I need.

-----Original Message-----
From: Edward Boadi [mailto:[hidden email]]
Sent: Wednesday, July 19, 2006 2:37 PM
To: Moffitt, James (West); [hidden email]
Subject: RE: Convert Numeric Variables to String Variables

This works :

data list list (",") / id part1 part2 part3.
begin data
101,1256489784,1654879525,1598648959
102,4567891285,5689745827,9657849516
103,5784896547,6549784562,7896548954
end data.


string spart1 (A11).
string spart2 (A11).
string spart3 (A11).


COMPUTE      spart1   = string(part1,F10).
COMPUTE      spart2  = string(part2,F10) .
COMPUTE      spart3  = string(part3,F10) .
EXECUTE.



------Edward


-----Original Message-----
From: SPSSX(r) Discussion [mailto:[hidden email]]On Behalf Of
Jim Moffitt
Sent: Wednesday, July 19, 2006 3:09 PM
To: [hidden email]
Subject: Convert Numeric Variables to String Variables


I want to convert three numeric variables into three new string
variables.

Here's the code I wrote along with a sample data set.

data list list (",") / id part 1 part 2 part3.
begin data
101,1256489784,1654879525,1598648959
102,4567891285,5689745827,9657849516
103,5784896547,6549784562,7896548954
end data.

*The next three lines are intended to create the string variables.

string spart1 (A10).
string spart2 (A10).
string spart3 (A10).

*And the next three lines are intended to deposit the values in the
numeric variables in the string variables.

recode part1 into spart1.
recode part2 into spart2.
recode part3 into spart3.

When I run the code I get the following error message after the first
recode line.

>Error # 4631 in column 14. Text: into

>On the RECODE command, the list of variables to be recoded includes the

>name of a nonexistent variable.

>This command not executed.

Any suggestions would be appreciated.