Trouble Recoding

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

Trouble Recoding

leeshification
I'm trying recode my age variables (ages 17-24) into new variables (0-7).

I ran the following:

RECODE Age ('17' = '0') ('18' = '1') ('19'= '2') ('20' = '3') ('21' = '4') ('22' = '5') ('23' = '6') ('24' = '7') INTO Age1.
EXECUTE.

The following error shows up when I try to do so:
 
>Error # 4655 in column 13.  Text: 17
>The RECODE command attempts to test a numeric value for having a string value.
>Execution of this command stops.
EXECUTE.

What am I doing wrong? Thanks so much!
Reply | Threaded
Open this post in threaded view
|

Re: Trouble Recoding

Bruce Weaver
Administrator
Your RECODE command is treating both Age and Age1 as if they are string variables.  The error message suggests that Age is numeric.  If Age *is* numeric, and if Age1 is also numeric (or does not exist yet), try this:

COMPUTE Age1 = Age-17.
FORMATS Age1(F1).
CROSSTABS Age by Age1. /* Verify that it worked.

And if (for some reason that I can't imagine) Age1 has to be a String variable, use ALTER TYPE to change it.

ALTER TYPE Age1(A1).

HTH.


leeshification wrote
I'm trying recode my age variables (ages 17-24) into new variables (0-7).

I ran the following:

RECODE Age ('17' = '0') ('18' = '1') ('19'= '2') ('20' = '3') ('21' = '4') ('22' = '5') ('23' = '6') ('24' = '7') INTO Age1.
EXECUTE.

The following error shows up when I try to do so:
 
>Error # 4655 in column 13.  Text: 17
>The RECODE command attempts to test a numeric value for having a string value.
>Execution of this command stops.
EXECUTE.

What am I doing wrong? Thanks so much!
--
Bruce Weaver
bweaver@lakeheadu.ca
http://sites.google.com/a/lakeheadu.ca/bweaver/

"When all else fails, RTFM."

NOTE: My Hotmail account is not monitored regularly.
To send me an e-mail, please use the address shown above.
Reply | Threaded
Open this post in threaded view
|

Re: Trouble Recoding

Salbod
In reply to this post by leeshification
If Age is numeric then single quotes aren't needed. I hope this helps. Steve

Sent from my iPad

> On Jun 16, 2017, at 7:22 PM, leeshification <[hidden email]> wrote:
>
> I'm trying recode my age variables (ages 17-24) into new variables (0-7).
>
> I ran the following:
>
> RECODE Age ('17' = '0') ('18' = '1') ('19'= '2') ('20' = '3') ('21' = '4')
> ('22' = '5') ('23' = '6') ('24' = '7') INTO Age1.
> EXECUTE.
>
> The following error shows up when I try to do so:
>
>> Error # 4655 in column 13.  Text: 17
>> The RECODE command attempts to test a numeric value for having a string
> value.
>> Execution of this command stops.
> EXECUTE.
>
> What am I doing wrong? Thanks so much!
>
>
>
> --
> View this message in context: http://spssx-discussion.1045642.n5.nabble.com/Trouble-Recoding-tp5734428.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

=====================
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
Reply | Threaded
Open this post in threaded view
|

Re: Trouble Recoding

leeshification
Yes thank you so much!

I have another question....

Again with recoding.

I'm trying to recode some variables into new names. They're already numbers on a scale of -3 to 3, as seen below:

RECODE BoyfriendGirlfriendBDView FatherBDView MotherBDView SiblingsBDView ProfessorBDView ClassmatesBDView CloseFriendsBDView SupervisorBossBDView (-3=-3) (-2=-2) (-1=-1) (0=0) (1=1) (2=2) (3=3) INTO SN1a SN2a SN3a SN4a SN5a SN6a SN7a SN8a.
EXECUTE.

This is the message I get:

RECODE On the RECODE command, all the variables to be recoded must be of the same type.  That is, all must be string variables, or all must be numeric variables.

Any thoughts?