Combinations of two variables?

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

Combinations of two variables?

Robert L

This might be a trivial problem, but I’m stuck. Two variables, one a string variable containing county names and the other numeric codes for each of the counties. I would like to assign value labels to the numeric codes using the text from the string variable. The plan was to extract a list of all combinations of the two and use this list in a “VALUE LABELS…” sequence. I don’t need to know how many of each combination there are, I just need the actual combinations. SUMMARIZE don’t seem to work because there are no statistics involved. Any suggestions? Or possibly workarounds: is it possible to assign text in one variable to value labels in a numeric variable in some better way than to edit a VALUE LABELS sequence?

 

Robert

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

Re: Combinations of two variables?

Bruce Weaver
Administrator
Unless it is essential to retain the original numeric codes for countries for some reason, I would use AUTORECODE on the string variable to generate a numeric variable with country names as value labels.  


Robert Lundqvist-3 wrote
This might be a trivial problem, but I’m stuck. Two variables, one a string variable containing county names and the other numeric codes for each of the counties. I would like to assign value labels to the numeric codes using the text from the string variable. The plan was to extract a list of all combinations of the two and use this list in a “VALUE LABELS…” sequence. I don’t need to know how many of each combination there are, I just need the actual combinations. SUMMARIZE don’t seem to work because there are no statistics involved. Any suggestions? Or possibly workarounds: is it possible to assign text in one variable to value labels in a numeric variable in some better way than to edit a VALUE LABELS sequence?

Robert

=====================
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: Combinations of two variables?

PRogman
In reply to this post by Robert L
Reply | Threaded
Open this post in threaded view
|

Re: Combinations of two variables?

Jon Peck
In reply to this post by Robert L
The STATS VALLBLS FROMDATA extension command might be applicable here.  Some extracts from the  syntax help.

Create value labels for a set of variables using values of other variables for the labels.  It also checks for conflicts and duplicate labels.  It generates a syntax file of  VALUE LABEL commands.

STATS VALLBLS FROMDATA
VARIABLES = variables or VARPATTERN = “regular expression
LBLVARS = string variables or LBLPATTERN = “regular expression

Example:
STATS VALLBLS FROMDATA VARIABLES = x1 TO x5 LBLVARS = label.

This command creates value labels for a set of variables using values of other variables for the labels. If x is a variable having values 1,2,3 and xlabel is a variable having values 'a''b''c', value labels for x are created as

1 'a'
2 'b'
3 'c'

VARIABLES lists the variables for which value labels should be produced. TO is supported, but ALL would not make sense here.

VARPATTERN is a regular expression in quotes that maps to the variables to be labelled. Specify either VARIABLES or VARPATTERN but not both. See below for some pattern examples.

LBLVARS lists the variables containing the labels corresponding to the variables to be labelled. TO is supported but ALL would not make sense. Numeric variables are automatically excluded.

LBLPATTERN lists a regular expression in quotes that expands to the list of label variables. Numeric variables are automatically excluded. The number of label variables can be one to apply the same set of labels to all the selected variables or as many as there are input variables. If a label variable value is blank, no value label is generated from it.



On Mon, Jun 27, 2016 at 3:08 AM, Robert Lundqvist <[hidden email]> wrote:

This might be a trivial problem, but I’m stuck. Two variables, one a string variable containing county names and the other numeric codes for each of the counties. I would like to assign value labels to the numeric codes using the text from the string variable. The plan was to extract a list of all combinations of the two and use this list in a “VALUE LABELS…” sequence. I don’t need to know how many of each combination there are, I just need the actual combinations. SUMMARIZE don’t seem to work because there are no statistics involved. Any suggestions? Or possibly workarounds: is it possible to assign text in one variable to value labels in a numeric variable in some better way than to edit a VALUE LABELS sequence?

 

Robert

===================== 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: Combinations of two variables?

Turner, John E. (VADOC)
In reply to this post by Robert L

This is a pretty easy way to address this problem Rob….

 

*********this writes a label file syntax*******.

write

                outfile = 'Y:\Location\label_1.sps'

                /"add value labels NameSuffixType " NameSuffixType " " NameSuffixTypeDesc ".".

EXECUTE.

 

******This runs the label file syntax****.

Insert

                file = 'Y:\Location\label_1.sps'.

 

JT

 

From: SPSSX(r) Discussion [mailto:[hidden email]] On Behalf Of Robert Lundqvist
Sent: Monday, June 27, 2016 5:09 AM
To: [hidden email]
Subject: Combinations of two variables?

 

This might be a trivial problem, but I’m stuck. Two variables, one a string variable containing county names and the other numeric codes for each of the counties. I would like to assign value labels to the numeric codes using the text from the string variable. The plan was to extract a list of all combinations of the two and use this list in a “VALUE LABELS…” sequence. I don’t need to know how many of each combination there are, I just need the actual combinations. SUMMARIZE don’t seem to work because there are no statistics involved. Any suggestions? Or possibly workarounds: is it possible to assign text in one variable to value labels in a numeric variable in some better way than to edit a VALUE LABELS sequence?

 

Robert

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