how to recode string variables

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

how to recode string variables

vstirkey

Good morning,

We have a variable that contains descriptions of living arrangements ‘own residence’, ‘friend’s home’, ‘supported living (MH)’  and so on. If I run a simple frequency to confirm how these values appear/should be written, the values that have ‘are displayed correctly in the output. If I try to recode to numeric values using the menu bar or by writing syntax, I get error messages that I don’t understand-  

              

STRING Residence (A50).

RECODE LIVING_SITUATION ('Own Residence'='1') ('Assisted Living Resdence (ALR)'='2') ('Friend's

    Home'='3') ('Relative's Home'='4') ('Children's Residence'='5') (ELSE='0') INTO Residence.

 

Warning # 208 in column 77.  Text: ) INTO Residence

A text string is not correctly enclosed in quotation marks on the command

line.  Literals may not be continued across command lines without the use of

the continuation symbol '+'.

 

Error # 4245 in column 95.  Text: s

Unrecognized text appears on the command where either a number, a text string,

or a keyword was expected.

Execution of this command stops.

EXECUTE.

SORT CASES BY LIVING_SITUATION (A).

 

Any ideas would be greatly appreciated!

 

 

              

 

Vicki L. Stirkey

OMHSAS l Bureau of Quality Management and Data Review

112 East Azalea Drive l Hbg PA  17110

Phone: 717.705.8198 l Fax: 717.772.6737

www.dpw.state.pa.us

 

Reply | Threaded
Open this post in threaded view
|

Re: how to recode string variables

Rick Oliver-3
You have enclosed values that contain single quotes in single quotes. Instead of 'xxx's yyy', use "xxx's yyy".

Also, why are you creating a new string variable that is, in fact, numeric?

Rick Oliver
Senior Information Developer
IBM Business Analytics (SPSS)
E-mail: [hidden email]




From:        "Stirkey, Vicki" <[hidden email]>
To:        [hidden email],
Date:        12/05/2013 09:47 AM
Subject:        how to recode string variables
Sent by:        "SPSSX(r) Discussion" <[hidden email]>




Good morning,
We have a variable that contains descriptions of living arrangements ‘own residence’, ‘friend’s home’, ‘supported living (MH)’  and so on. If I run a simple frequency to confirm how these values appear/should be written, the values that have ‘are displayed correctly in the output. If I try to recode to numeric values using the menu bar or by writing syntax, I get error messages that I don’t understand-  
               
STRING Residence (A50).
RECODE LIVING_SITUATION ('Own Residence'='1') ('Assisted Living Resdence (ALR)'='2') ('Friend's
    Home'='3') ('Relative's Home'='4') ('Children's Residence'='5') (ELSE='0') INTO Residence.
 
Warning # 208 in column 77.  Text: ) INTO Residence
A text string is not correctly enclosed in quotation marks on the command
line.  Literals may not be continued across command lines without the use of
the continuation symbol '+'.
 
Error # 4245 in column 95.  Text: s
Unrecognized text appears on the command where either a number, a text string,
or a keyword was expected.
Execution of this command stops.
EXECUTE.
SORT CASES BY LIVING_SITUATION (A).
 
Any ideas would be greatly appreciated!
 
 
               
 
Vicki L. Stirkey
OMHSAS l Bureau of Quality Management and Data Review
112 East Azalea Drive l Hbg PA  17110
Phone: 717.705.8198 l Fax: 717.772.6737
www.dpw.state.pa.us
 
Reply | Threaded
Open this post in threaded view
|

Re: how to recode string variables

Bruce Weaver
Administrator
RO: "Also, why are you creating a new string variable that is, in fact, numeric?"

Good question!  AUTORECODE would seem to be what is required here!  


Rick Oliver wrote
You have enclosed values that contain single quotes in single quotes.
Instead of 'xxx's yyy', use "xxx's yyy".

Also, why are you creating a new string variable that is, in fact,
numeric?

Rick Oliver
Senior Information Developer
IBM Business Analytics (SPSS)
E-mail: [hidden email]



From:   "Stirkey, Vicki" <[hidden email]>
To:     [hidden email],
Date:   12/05/2013 09:47 AM
Subject:        how to recode string variables
Sent by:        "SPSSX(r) Discussion" <[hidden email]>



Good morning,
We have a variable that contains descriptions of living arrangements ‘own
residence’, ‘friend’s home’, ‘supported living (MH)’  and so on. If I run
a simple frequency to confirm how these values appear/should be written,
the values that have ‘are displayed correctly in the output. If I try to
recode to numeric values using the menu bar or by writing syntax, I get
error messages that I don’t understand-
 
STRING Residence (A50).
RECODE LIVING_SITUATION ('Own Residence'='1') ('Assisted Living Resdence
(ALR)'='2') ('Friend's
    Home'='3') ('Relative's Home'='4') ('Children's Residence'='5')
(ELSE='0') INTO Residence.
 
Warning # 208 in column 77.  Text: ) INTO Residence
A text string is not correctly enclosed in quotation marks on the command
line.  Literals may not be continued across command lines without the use
of
the continuation symbol '+'.
 
Error # 4245 in column 95.  Text: s
Unrecognized text appears on the command where either a number, a text
string,
or a keyword was expected.
Execution of this command stops.
EXECUTE.
SORT CASES BY LIVING_SITUATION (A).
 
Any ideas would be greatly appreciated!
 
 
 
 
Vicki L. Stirkey
OMHSAS l Bureau of Quality Management and Data Review
112 East Azalea Drive l Hbg PA  17110
Phone: 717.705.8198 l Fax: 717.772.6737
www.dpw.state.pa.us
--
Bruce Weaver
bweaver@lakeheadu.ca
http://sites.google.com/a/lakeheadu.ca/bweaver/

"When all else fails, RTFM."

PLEASE NOTE THE FOLLOWING: 
1. My Hotmail account is not monitored regularly. To send me an e-mail, please use the address shown above.
2. The SPSSX Discussion forum on Nabble is no longer linked to the SPSSX-L listserv administered by UGA (https://listserv.uga.edu/).
Reply | Threaded
Open this post in threaded view
|

Re: how to recode string variables

Rick Oliver-3
Autorecode won't handle the "ELSE" condition.

Rick Oliver
Senior Information Developer
IBM Business Analytics (SPSS)
E-mail: [hidden email]




From:        Bruce Weaver <[hidden email]>
To:        [hidden email],
Date:        12/05/2013 10:25 AM
Subject:        Re: how to recode string variables
Sent by:        "SPSSX(r) Discussion" <[hidden email]>




RO: "Also, why are you creating a new string variable that is, in fact,
numeric?"

Good question!  AUTORECODE would seem to be what is required here!



Rick Oliver wrote
> You have enclosed values that contain single quotes in single quotes.
> Instead of 'xxx's yyy', use "xxx's yyy".
>
> Also, why are you creating a new string variable that is, in fact,
> numeric?
>
> Rick Oliver
> Senior Information Developer
> IBM Business Analytics (SPSS)
> E-mail:

> oliverr@.ibm

>
>
>
> From:   "Stirkey, Vicki" &lt;

> vstirkey@

> &gt;
> To:

> SPSSX-L@.uga

> ,
> Date:   12/05/2013 09:47 AM
> Subject:        how to recode string variables
> Sent by:        "SPSSX(r) Discussion" &lt;

> SPSSX-L@.uga

> &gt;
>
>
>
> Good morning,
> We have a variable that contains descriptions of living arrangements ‘own
> residence’, ‘friend’s home’, ‘supported living (MH)’  and so on. If I run
> a simple frequency to confirm how these values appear/should be written,
> the values that have ‘are displayed correctly in the output. If I try to
> recode to numeric values using the menu bar or by writing syntax, I get
> error messages that I don’t understand-
>
> STRING Residence (A50).
> RECODE LIVING_SITUATION ('Own Residence'='1') ('Assisted Living Resdence
> (ALR)'='2') ('Friend's
>     Home'='3') ('Relative's Home'='4') ('Children's Residence'='5')
> (ELSE='0') INTO Residence.
>
> Warning # 208 in column 77.  Text: ) INTO Residence
> A text string is not correctly enclosed in quotation marks on the command
> line.  Literals may not be continued across command lines without the use
> of
> the continuation symbol '+'.
>
> Error # 4245 in column 95.  Text: s
> Unrecognized text appears on the command where either a number, a text
> string,
> or a keyword was expected.
> Execution of this command stops.
> EXECUTE.
> SORT CASES BY LIVING_SITUATION (A).
>
> Any ideas would be greatly appreciated!
>
>
>
>
> Vicki L. Stirkey
> OMHSAS l Bureau of Quality Management and Data Review
> 112 East Azalea Drive l Hbg PA  17110
> Phone: 717.705.8198 l Fax: 717.772.6737
>
www.dpw.state.pa.us





-----
--
Bruce Weaver
[hidden email]
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.

--
View this message in context:
http://spssx-discussion.1045642.n5.nabble.com/how-to-recode-string-variables-tp5723456p5723459.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


Reply | Threaded
Open this post in threaded view
|

Re: how to recode string variables

John F Hall
In reply to this post by Bruce Weaver
Vicki

Your syntax should look something like this:

RECODE LIVING_SITUATION
 ('Own Residence' = 1)
 ('Assisted Living Resdence (ALR)' = 2)
 ("Friend's Home" = 3)
 ("Relative's Home" = 4)
 ("Children's Residence" = 5)
 (ELSE = 0) INTO Residence.

You also need to get rid of the decimal places in the new variable:

Format residence (f1.0).

. . and add value labels:

Val lab residence
        1 'Own Residence'
        2 'Assisted Living Resdence (ALR)'
        3 "Friend's Home"
        4 "Relative's Home"
        5 "Children's Residence".

To find out more see my tutorial on data transformation on:
http://surveyresearch.weebly.com/23-data-transformations.html


John F Hall (Mr)
[Retired academic survey researcher]

Email:   [hidden email]
Website: www.surveyresearch.weebly.com
SPSS start page:  www.surveyresearch.weebly.com/spss-without-tears.html







-----Original Message-----
From: SPSSX(r) Discussion [mailto:[hidden email]] On Behalf Of Bruce Weaver
Sent: 05 December 2013 17:25
To: [hidden email]
Subject: Re: how to recode string variables

RO: "Also, why are you creating a new string variable that is, in fact, numeric?"

Good question!  AUTORECODE would seem to be what is required here!



Rick Oliver wrote

> You have enclosed values that contain single quotes in single quotes.
> Instead of 'xxx's yyy', use "xxx's yyy".
>
> Also, why are you creating a new string variable that is, in fact,
> numeric?
>
> Rick Oliver
> Senior Information Developer
> IBM Business Analytics (SPSS)
> E-mail:

> oliverr@.ibm

>
>
>
> From:   "Stirkey, Vicki" &lt;

> vstirkey@

> &gt;
> To:

> SPSSX-L@.uga

> ,
> Date:   12/05/2013 09:47 AM
> Subject:        how to recode string variables
> Sent by:        "SPSSX(r) Discussion" &lt;

> SPSSX-L@.uga

> &gt;
>
>
>
> Good morning,
> We have a variable that contains descriptions of living arrangements
> ‘own residence’, ‘friend’s home’, ‘supported living (MH)’  and so on.
> If I run a simple frequency to confirm how these values appear/should
> be written, the values that have ‘are displayed correctly in the
> output. If I try to recode to numeric values using the menu bar or by
> writing syntax, I get error messages that I don’t understand-
>
> STRING Residence (A50).
> RECODE LIVING_SITUATION ('Own Residence'='1') ('Assisted Living
> Resdence
> (ALR)'='2') ('Friend's
>     Home'='3') ('Relative's Home'='4') ('Children's Residence'='5')
> (ELSE='0') INTO Residence.
>
> Warning # 208 in column 77.  Text: ) INTO Residence A text string is
> not correctly enclosed in quotation marks on the command line.
> Literals may not be continued across command lines without the use of
> the continuation symbol '+'.
>
> Error # 4245 in column 95.  Text: s
> Unrecognized text appears on the command where either a number, a text
> string, or a keyword was expected.
> Execution of this command stops.
> EXECUTE.
> SORT CASES BY LIVING_SITUATION (A).
>
> Any ideas would be greatly appreciated!
>
>
>
>
> Vicki L. Stirkey
> OMHSAS l Bureau of Quality Management and Data Review
> 112 East Azalea Drive l Hbg PA  17110
> Phone: 717.705.8198 l Fax: 717.772.6737 www.dpw.state.pa.us





-----
--
Bruce Weaver
[hidden email]
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.

--
View this message in context: http://spssx-discussion.1045642.n5.nabble.com/how-to-recode-string-variables-tp5723456p5723459.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: how to recode string variables

Art Kendall
In reply to this post by vstirkey
open a new instance of SPSS.
paste the syntax below into a syntax window.
run it.

* make up some data.
data list fixed /living_situation (a50).

begin data
Own Residence
own Residence
Own residence
my own residence
Assisted Living Resdence
Assisted Living Residence
ALR
Children's Residence
my Kid's residence
Ralative's home
relative's home
with friends
with a friend
friend
end data.

*alphabetize entries and give them numeric codes.
autorecode living_situation /into residence /print.

*
regroup values and label them.
* redo recode until the crosstab looks right.

recode residence (1 thru 3=1)(4,6 =2) (7 thru 10 = 3)
(5,13,14=4)(11,12=5)(else=copy) into residence2.
value labels residence2
1 'Assisted Living'
2 'With Children'
3 'Own residence'
4 'with a friend'
5 'with a relative'.

*
check accuracy of recode.

crosstabs tables = residence by residence2.



Art Kendall
Social Research Consultants
On 12/5/2013 10:53 AM, Stirkey, Vicki-2 [via SPSSX Discussion] wrote:

Good morning,

We have a variable that contains descriptions of living arrangements ‘own residence’, ‘friend’s home’, ‘supported living (MH)’  and so on. If I run a simple frequency to confirm how these values appear/should be written, the values that have ‘are displayed correctly in the output. If I try to recode to numeric values using the menu bar or by writing syntax, I get error messages that I don’t understand-  

              

STRING Residence (A50).

RECODE LIVING_SITUATION ('Own Residence'='1') ('Assisted Living Resdence (ALR)'='2') ('Friend's

    Home'='3') ('Relative's Home'='4') ('Children's Residence'='5') (ELSE='0') INTO Residence.

 

Warning # 208 in column 77.  Text: ) INTO Residence

A text string is not correctly enclosed in quotation marks on the command

line.  Literals may not be continued across command lines without the use of

the continuation symbol '+'.

 

Error # 4245 in column 95.  Text: s

Unrecognized text appears on the command where either a number, a text string,

or a keyword was expected.

Execution of this command stops.

EXECUTE.

SORT CASES BY LIVING_SITUATION (A).

 

Any ideas would be greatly appreciated!

 

 

              

 

Vicki L. Stirkey

OMHSAS l Bureau of Quality Management and Data Review

112 East Azalea Drive l Hbg PA  17110

Phone: 717.705.8198 l Fax: 717.772.6737

www.dpw.state.pa.us

 




If you reply to this email, your message will be added to the discussion below:
http://spssx-discussion.1045642.n5.nabble.com/how-to-recode-string-variables-tp5723456.html
To start a new topic under SPSSX Discussion, email [hidden email]
To unsubscribe from SPSSX Discussion, click here.
NAML

Art Kendall
Social Research Consultants
Reply | Threaded
Open this post in threaded view
|

Re: how to recode string variables

John F Hall
In reply to this post by Rick Oliver-3

Doesn’t matter: all other strings will be allocated a code anyway.  I think my RECODE solution is better.

 

John F Hall (Mr)

[Retired academic survey researcher]

 

Email:   [hidden email] 

Website: www.surveyresearch.weebly.com

SPSS start page:  www.surveyresearch.weebly.com/spss-without-tears.html

  

  

 

 

 

 

 

From: SPSSX(r) Discussion [mailto:[hidden email]] On Behalf Of Rick Oliver
Sent: 05 December 2013 17:41
To: [hidden email]
Subject: Re: how to recode string variables

 

Autorecode won't handle the "ELSE" condition.

Rick Oliver
Senior Information Developer
IBM Business Analytics (SPSS)
E-mail: [hidden email]




From:        Bruce Weaver <[hidden email]>
To:        [hidden email],
Date:        12/05/2013 10:25 AM
Subject:        Re: how to recode string variables
Sent by:        "SPSSX(r) Discussion" <[hidden email]>





RO: "Also, why are you creating a new string variable that is, in fact,
numeric?"

Good question!  AUTORECODE would seem to be what is required here!



Rick Oliver wrote
> You have enclosed values that contain single quotes in single quotes.
> Instead of 'xxx's yyy', use "xxx's yyy".
>
> Also, why are you creating a new string variable that is, in fact,
> numeric?
>
> Rick Oliver
> Senior Information Developer
> IBM Business Analytics (SPSS)
> E-mail:

> [hidden email]

>
>
>
> From:   "Stirkey, Vicki" &lt;

> vstirkey@

> &gt;
> To:

> [hidden email]

> ,
> Date:   12/05/2013 09:47 AM
> Subject:        how to recode string variables
> Sent by:        "SPSSX(r) Discussion" &lt;

> [hidden email]

> &gt;
>
>
>
> Good morning,
> We have a variable that contains descriptions of living arrangements ‘own
> residence’, ‘friend’s home’, ‘supported living (MH)’  and so on. If I run
> a simple frequency to confirm how these values appear/should be written,
> the values that have ‘are displayed correctly in the output. If I try to
> recode to numeric values using the menu bar or by writing syntax, I get
> error messages that I don’t understand-
>
> STRING Residence (A50).
> RECODE LIVING_SITUATION ('Own Residence'='1') ('Assisted Living Resdence
> (ALR)'='2') ('Friend's
>     Home'='3') ('Relative's Home'='4') ('Children's Residence'='5')
> (ELSE='0') INTO Residence.
>
> Warning # 208 in column 77.  Text: ) INTO Residence
> A text string is not correctly enclosed in quotation marks on the command
> line.  Literals may not be continued across command lines without the use
> of
> the continuation symbol '+'.
>
> Error # 4245 in column 95.  Text: s
> Unrecognized text appears on the command where either a number, a text
> string,
> or a keyword was expected.
> Execution of this command stops.
> EXECUTE.
> SORT CASES BY LIVING_SITUATION (A).
>
> Any ideas would be greatly appreciated!
>
>
>
>
> Vicki L. Stirkey
> OMHSAS l Bureau of Quality Management and Data Review
> 112 East Azalea Drive l Hbg PA  17110
> Phone: 717.705.8198 l Fax: 717.772.6737
>
www.dpw.state.pa.us





-----
--
Bruce Weaver
[hidden email]
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.

--
View this message in context:
http://spssx-discussion.1045642.n5.nabble.com/how-to-recode-string-variables-tp5723456p5723459.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

Reply | Threaded
Open this post in threaded view
|

Re: how to recode string variables

Rick Oliver-3
In regard to the suggestion to use Autorecode, it matters, unless you don't care what numeric codes get assigned -- but the presence of (ELSE=0) suggests otherwise. Also, still in regard to Autorecode, if the actual numeric values matter for some reason, then Autorecode won't provide the numeric codes the user wants. You could, however, address these issues with a custom Autorecode template.

Rick Oliver
Senior Information Developer
IBM Business Analytics (SPSS)
E-mail: [hidden email]




From:        John F Hall <[hidden email]>
To:        [hidden email],
Date:        12/05/2013 12:27 PM
Subject:        Re: how to recode string variables
Sent by:        "SPSSX(r) Discussion" <[hidden email]>




Doesn’t matter: all other strings will be allocated a code anyway.  I think my RECODE solution is better.

 

John F Hall (Mr)

[Retired academic survey researcher]

 

Email:   johnfhall@... 

Website: www.surveyresearch.weebly.com

SPSS start page:  www.surveyresearch.weebly.com/spss-without-tears.html

  

  

 

 

 

 

 

From: SPSSX(r) Discussion [[hidden email]] On Behalf Of Rick Oliver
Sent:
05 December 2013 17:41
To:
[hidden email]
Subject:
Re: how to recode string variables

 

Autorecode won't handle the "ELSE" condition.

Rick Oliver
Senior Information Developer
IBM Business Analytics (SPSS)
E-mail:
oliverr@...



From:        
Bruce Weaver <bruce.weaver@...>
To:        
[hidden email],
Date:        
12/05/2013 10:25 AM
Subject:        
Re: how to recode string variables
Sent by:        
"SPSSX(r) Discussion" <[hidden email]>





RO: "Also, why are you creating a new string variable that is, in fact,
numeric?"

Good question!  AUTORECODE would seem to be what is required here!



Rick Oliver wrote
> You have enclosed values that contain single quotes in single quotes.
> Instead of 'xxx's yyy', use "xxx's yyy".
>
> Also, why are you creating a new string variable that is, in fact,
> numeric?
>
> Rick Oliver
> Senior Information Developer
> IBM Business Analytics (SPSS)
> E-mail:

>
oliverr@.ibm

>
>
>
> From:   "Stirkey, Vicki" &lt;

> vstirkey@

> &gt;
> To:

>
[hidden email]

> ,
> Date:   12/05/2013 09:47 AM
> Subject:        how to recode string variables
> Sent by:        "SPSSX(r) Discussion" &lt;

>
[hidden email]

> &gt;
>
>
>
> Good morning,
> We have a variable that contains descriptions of living arrangements ‘own
> residence’, ‘friend’s home’, ‘supported living (MH)’  and so on. If I run
> a simple frequency to confirm how these values appear/should be written,
> the values that have ‘are displayed correctly in the output. If I try to
> recode to numeric values using the menu bar or by writing syntax, I get
> error messages that I don’t understand-
>
> STRING Residence (A50).
> RECODE LIVING_SITUATION ('Own Residence'='1') ('Assisted Living Resdence
> (ALR)'='2') ('Friend's
>     Home'='3') ('Relative's Home'='4') ('Children's Residence'='5')
> (ELSE='0') INTO Residence.
>
> Warning # 208 in column 77.  Text: ) INTO Residence
> A text string is not correctly enclosed in quotation marks on the command
> line.  Literals may not be continued across command lines without the use
> of
> the continuation symbol '+'.
>
> Error # 4245 in column 95.  Text: s
> Unrecognized text appears on the command where either a number, a text
> string,
> or a keyword was expected.
> Execution of this command stops.
> EXECUTE.
> SORT CASES BY LIVING_SITUATION (A).
>
> Any ideas would be greatly appreciated!
>
>
>
>
> Vicki L. Stirkey
> OMHSAS l Bureau of Quality Management and Data Review
> 112 East Azalea Drive l Hbg PA  17110
> Phone: 717.705.8198 l Fax: 717.772.6737
>
www.dpw.state.pa.us





-----
--
Bruce Weaver

bweaver@...
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.

--
View this message in context:
http://spssx-discussion.1045642.n5.nabble.com/how-to-recode-string-variables-tp5723456p5723459.html
Sent from the SPSSX Discussion mailing list archive at Nabble.com.

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

Reply | Threaded
Open this post in threaded view
|

Re: how to recode string variables

Bruce Weaver
Administrator
In reply to this post by Rick Oliver-3
That's true.  I'd not read the OP closely enough to notice the ELSE.  But as Art's solution shows, using AUTORECODE can still be a nice first step, eliminating the need for working with those long string values in a RECODE.

http://spssx-discussion.1045642.n5.nabble.com/how-to-recode-string-variables-tp5723456p5723465.html



Rick Oliver wrote
Autorecode won't handle the "ELSE" condition.

Rick Oliver
Senior Information Developer
IBM Business Analytics (SPSS)
E-mail: [hidden email]



From:   Bruce Weaver <[hidden email]>
To:     [hidden email],
Date:   12/05/2013 10:25 AM
Subject:        Re: how to recode string variables
Sent by:        "SPSSX(r) Discussion" <[hidden email]>



RO: "Also, why are you creating a new string variable that is, in fact,
numeric?"

Good question!  AUTORECODE would seem to be what is required here!



Rick Oliver wrote
> You have enclosed values that contain single quotes in single quotes.
> Instead of 'xxx's yyy', use "xxx's yyy".
>
> Also, why are you creating a new string variable that is, in fact,
> numeric?
>
> Rick Oliver
> Senior Information Developer
> IBM Business Analytics (SPSS)
> E-mail:

> oliverr@.ibm

>
>
>
> From:   "Stirkey, Vicki" <

> vstirkey@

> >
> To:

> SPSSX-L@.uga

> ,
> Date:   12/05/2013 09:47 AM
> Subject:        how to recode string variables
> Sent by:        "SPSSX(r) Discussion" <

> SPSSX-L@.uga

> >
>
>
>
> Good morning,
> We have a variable that contains descriptions of living arrangements
‘own
> residence’, ‘friend’s home’, ‘supported living (MH)’  and so on. If I
run
> a simple frequency to confirm how these values appear/should be written,
> the values that have ‘are displayed correctly in the output. If I try to
> recode to numeric values using the menu bar or by writing syntax, I get
> error messages that I don’t understand-
>
> STRING Residence (A50).
> RECODE LIVING_SITUATION ('Own Residence'='1') ('Assisted Living Resdence
> (ALR)'='2') ('Friend's
>     Home'='3') ('Relative's Home'='4') ('Children's Residence'='5')
> (ELSE='0') INTO Residence.
>
> Warning # 208 in column 77.  Text: ) INTO Residence
> A text string is not correctly enclosed in quotation marks on the
command
> line.  Literals may not be continued across command lines without the
use
> of
> the continuation symbol '+'.
>
> Error # 4245 in column 95.  Text: s
> Unrecognized text appears on the command where either a number, a text
> string,
> or a keyword was expected.
> Execution of this command stops.
> EXECUTE.
> SORT CASES BY LIVING_SITUATION (A).
>
> Any ideas would be greatly appreciated!
>
>
>
>
> Vicki L. Stirkey
> OMHSAS l Bureau of Quality Management and Data Review
> 112 East Azalea Drive l Hbg PA  17110
> Phone: 717.705.8198 l Fax: 717.772.6737
> www.dpw.state.pa.us





-----
--
Bruce Weaver
[hidden email]
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.

--
View this message in context:
http://spssx-discussion.1045642.n5.nabble.com/how-to-recode-string-variables-tp5723456p5723459.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
--
Bruce Weaver
bweaver@lakeheadu.ca
http://sites.google.com/a/lakeheadu.ca/bweaver/

"When all else fails, RTFM."

PLEASE NOTE THE FOLLOWING: 
1. My Hotmail account is not monitored regularly. To send me an e-mail, please use the address shown above.
2. The SPSSX Discussion forum on Nabble is no longer linked to the SPSSX-L listserv administered by UGA (https://listserv.uga.edu/).
Reply | Threaded
Open this post in threaded view
|

Re: how to recode string variables

Rick Oliver-3
Yup. Preserving the original values as value labels is a great feature of Autorecode.

Rick Oliver
Senior Information Developer
IBM Business Analytics (SPSS)
E-mail: [hidden email]




From:        Bruce Weaver <[hidden email]>
To:        [hidden email],
Date:        12/05/2013 01:05 PM
Subject:        Re: how to recode string variables
Sent by:        "SPSSX(r) Discussion" <[hidden email]>




That's true.  I'd not read the OP closely enough to notice the ELSE.  But as
Art's solution shows, using AUTORECODE can still be a nice first step,
eliminating the need for working with those long string values in a RECODE.

http://spssx-discussion.1045642.n5.nabble.com/how-to-recode-string-variables-tp5723456p5723465.html




Rick Oliver wrote
> Autorecode won't handle the "ELSE" condition.
>
> Rick Oliver
> Senior Information Developer
> IBM Business Analytics (SPSS)
> E-mail:

> oliverr@.ibm

>
>
>
> From:   Bruce Weaver &lt;

> bruce.weaver@

> &gt;
> To:

> SPSSX-L@.uga

> ,
> Date:   12/05/2013 10:25 AM
> Subject:        Re: how to recode string variables
> Sent by:        "SPSSX(r) Discussion" &lt;

> SPSSX-L@.uga

> &gt;
>
>
>
> RO: "Also, why are you creating a new string variable that is, in fact,
> numeric?"
>
> Good question!  AUTORECODE would seem to be what is required here!
>
>
>
> Rick Oliver wrote
>> You have enclosed values that contain single quotes in single quotes.
>> Instead of 'xxx's yyy', use "xxx's yyy".
>>
>> Also, why are you creating a new string variable that is, in fact,
>> numeric?
>>
>> Rick Oliver
>> Senior Information Developer
>> IBM Business Analytics (SPSS)
>> E-mail:
>
>> oliverr@.ibm
>
>>
>>
>>
>> From:   "Stirkey, Vicki" &lt;
>
>> vstirkey@
>
>> &gt;
>> To:
>
>> SPSSX-L@.uga
>
>> ,
>> Date:   12/05/2013 09:47 AM
>> Subject:        how to recode string variables
>> Sent by:        "SPSSX(r) Discussion" &lt;
>
>> SPSSX-L@.uga
>
>> &gt;
>>
>>
>>
>> Good morning,
>> We have a variable that contains descriptions of living arrangements
> ‘own
>> residence’, ‘friend’s home’, ‘supported living (MH)’  and so on. If I
> run
>> a simple frequency to confirm how these values appear/should be written,
>> the values that have ‘are displayed correctly in the output. If I try to
>> recode to numeric values using the menu bar or by writing syntax, I get
>> error messages that I don’t understand-
>>
>> STRING Residence (A50).
>> RECODE LIVING_SITUATION ('Own Residence'='1') ('Assisted Living Resdence
>> (ALR)'='2') ('Friend's
>>     Home'='3') ('Relative's Home'='4') ('Children's Residence'='5')
>> (ELSE='0') INTO Residence.
>>
>> Warning # 208 in column 77.  Text: ) INTO Residence
>> A text string is not correctly enclosed in quotation marks on the
> command
>> line.  Literals may not be continued across command lines without the
> use
>> of
>> the continuation symbol '+'.
>>
>> Error # 4245 in column 95.  Text: s
>> Unrecognized text appears on the command where either a number, a text
>> string,
>> or a keyword was expected.
>> Execution of this command stops.
>> EXECUTE.
>> SORT CASES BY LIVING_SITUATION (A).
>>
>> Any ideas would be greatly appreciated!
>>
>>
>>
>>
>> Vicki L. Stirkey
>> OMHSAS l Bureau of Quality Management and Data Review
>> 112 East Azalea Drive l Hbg PA  17110
>> Phone: 717.705.8198 l Fax: 717.772.6737
>>
www.dpw.state.pa.us
>
>
>
>
>
> -----
> --
> Bruce Weaver

> bweaver@

>
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.
>
> --
> View this message in context:
>
http://spssx-discussion.1045642.n5.nabble.com/how-to-recode-string-variables-tp5723456p5723459.html
>
> Sent from the SPSSX Discussion mailing list archive at Nabble.com.
>
> =====================
> To manage your subscription to SPSSX-L, send a message to

> LISTSERV@.UGA

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





-----
--
Bruce Weaver
[hidden email]
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.

--
View this message in context:
http://spssx-discussion.1045642.n5.nabble.com/how-to-recode-string-variables-tp5723456p5723471.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