Recoding

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

Recoding

leeshification
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? Thanks so much!
Reply | Threaded
Open this post in threaded view
|

Recoding

John F Hall

I thought this had already been answered.

One suggestion was ALTER TYPE, but you can also use

 

*Use CTRL+H to change ( to (" and = to " = .

 

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. 

 

FORMATS SN1a SN2a SN3a SN4 SN5a SN6a SN7a SN8a (f2.0).

 

If you syntax instead of the GUI you will find it much quicker to type the shorter variable names!

 

John F Hall

[Retired academic survey researcher]

 

Website:          http://surveyresearch.weebly.com/

SPSS course:   http://surveyresearch.weebly.com/1-survey-analysis-workshop-spss.html

Research:        http://surveyresearch.weebly.com/3-subjective-social-indicators-quality-of-life.html

 



 

 

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

David Marso
Administrator
In reply to this post by leeshification
The error message could hardly be more obvious!
Check the variable types and make them to be consistent.

leeshification wrote
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? Thanks so much!
Please reply to the list and not to my personal email.
Those desiring my consulting or training services please feel free to email me.
---
"Nolite dare sanctum canibus neque mittatis margaritas vestras ante porcos ne forte conculcent eas pedibus suis."
Cum es damnatorum possederunt porcos iens ut salire off sanguinum cliff in abyssum?"
Reply | Threaded
Open this post in threaded view
|

Re: Recoding

PRogman
In reply to this post by leeshification
Have you considered COMPUTE? You are not doing any recoding.

COMPUTE SN1a = BoyfriendGirlfriendBDView .
COMPUTE SN2a = FatherBDView.
COMPUTE SN3a ...
COMPUTE SN8a = SupervisorBossBDView.


or maybe like

DO REPEAT   a = BoyfriendGirlfriendBDView FatherBDView MotherBDView SiblingsBDView  ProfessorBDView ClassmatesBDView CloseFriendsBDView SupervisorBossBDView
 /b = SN1a SN2a SN3a SN4a SN5a SN6a SN7a SN8a.
COMPUTE a = b.
END REPEAT.


/PR

leeshification wrote
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? Thanks so much!
Reply | Threaded
Open this post in threaded view
|

Re: Recoding

Jon Peck
In reply to this post by David Marso
What puzzles me in why you are using RECODE here.  Why not a simple COMPUTE? The only difference here is that if there are other input values than the ones listed, they will be mapped to system missing or blank in the output variables.

Or, if this is just a renaming, use RENAME VARIABLES.

On Mon, Jun 26, 2017 at 10:53 AM, David Marso <[hidden email]> wrote:
The error message could hardly be more obvious!
Check the variable types and make them to be consistent.


leeshification wrote
> 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? Thanks so much!





-----
Please reply to the list and not to my personal email.
Those desiring my consulting or training services please feel free to email me.
---
"Nolite dare sanctum canibus neque mittatis margaritas vestras ante porcos ne forte conculcent eas pedibus suis."
Cum es damnatorum possederunt porcos iens ut salire off sanguinum cliff in abyssum?"
--
View this message in context: http://spssx-discussion.1045642.n5.nabble.com/Recoding-tp5734461p5734463.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



--
Jon K Peck
[hidden email]

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

MLIves

The compute examples from earlier (e.g. COMPUTE SN1a = BoyfriendGirlfriendBDView .) would have similar data type errors.

 

Alternative: (b and a reversed from earlier example).

DO REPEAT  

   a = BoyfriendGirlfriendBDView FatherBDView MotherBDView SiblingsBDView  ProfessorBDView ClassmatesBDView CloseFriendsBDView SupervisorBossBDView 

   /b = SN1a SN2a SN3a SN4a SN5a SN6a SN7a SN8a.

  COMPUTE b = Number(a,F2.0).

END REPEAT.

 

Would a simple rename and Alter Type (WITH Variable LABELS) be sufficient? Or do the original variables need to be retained?

 

Rename variables

 (BoyfriendGirlfriendBDView FatherBDView MotherBDView SiblingsBDView ProfessorBDView ClassmatesBDView CloseFriendsBDView SupervisorBossBDView

= SN1a SN2a SN3a SN4a SN5a SN6a SN7a SN8a).

ALTER TYPE SN1a SN2a SN3a SN4a SN5a SN6a SN7a SN8a (F2.0).

 

Melissa

From: SPSSX(r) Discussion [mailto:[hidden email]] On Behalf Of Jon Peck
Sent: Monday, June 26, 2017 1:58 PM
To: [hidden email]
Subject: Re: [SPSSX-L] Recoding

 

What puzzles me in why you are using RECODE here.  Why not a simple COMPUTE? The only difference here is that if there are other input values than the ones listed, they will be mapped to system missing or blank in the output variables.

 

Or, if this is just a renaming, use RENAME VARIABLES.

 

On Mon, Jun 26, 2017 at 10:53 AM, David Marso <[hidden email]> wrote:

The error message could hardly be more obvious!
Check the variable types and make them to be consistent.


leeshification wrote
> 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? Thanks so much!





-----
Please reply to the list and not to my personal email.
Those desiring my consulting or training services please feel free to email me.
---
"Nolite dare sanctum canibus neque mittatis margaritas vestras ante porcos ne forte conculcent eas pedibus suis."
Cum es damnatorum possederunt porcos iens ut salire off sanguinum cliff in abyssum?"
--
View this message in context: http://spssx-discussion.1045642.n5.nabble.com/Recoding-tp5734461p5734463.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



 

--

Jon K Peck
[hidden email]

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




This correspondence contains proprietary information some or all of which may be legally privileged; it is for the intended recipient only. If you are not the intended recipient you must not use, disclose, distribute, copy, print, or rely on this correspondence and completely dispose of the correspondence immediately. Please notify the sender if you have received this email in error. NOTE: Messages to or from the State of Connecticut domain may be subject to the Freedom of Information statutes and regulations.

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

Rich Ulrich
In reply to this post by leeshification

For copying values, you can use RENAME var1 (else=copy) INTO newvara.


If you use the RENAME VARIABLES command, you save the other characteristics like MISSING.

That seems useful for your example. 


The Error message explicitly says that you have included a mixture of string and numeric variables - 

I don't know if that is the message that SPSS will give if you have incorrectly tried to CONVERT string

to numerical values without giving the old values in quotes.  If that is what you want to do, use (CONVERT).


-- 

Rich Ulrich 


From: SPSSX(r) Discussion <[hidden email]> on behalf of leeshification <[hidden email]>
Sent: Sunday, July 23, 2017 10:24:39 AM
To: [hidden email]
Subject: Recoding
 
I'm trying to rename some variables that were rated on a scale from -3 to 3.
I want each of the variables to be renamed to SN1a, SN2a, SN3a, etc....

This is what I tried to run:

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 was the error I received:

159 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.

Anyone have any ideas? Thanks so much!



--
View this message in context: http://spssx-discussion.1045642.n5.nabble.com/Recoding-tp5734567.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