Re: Is there an easy way to lable the values of one variable with the values of an other?

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

Re: Is there an easy way to lable the values of one variable with the values of an other?

Dennis Deck
If you have the codes in a database you can create a report to write SPSS code.
I used to do same thing within SPSS - SPSS code to write SPSS code.
I don't have access to an example right this minute unfortunately.
But even a simple code list is easy to turn into syntax:

  FA_CODE     FA_TYPE_DESCR
  "2"         "Loan/Work Replacing Grant"
  "L"         "Loan"
  "W"         "Work/Study"

Recode as:

VALUE LABELS
  FA_CODE
  "2"         "Loan/Work Replacing Grant"
  "L"         "Loan"
  "W"         "Work/Study"
  .


Dennis Deck, PhD
RMC Research Corporation
111 SW Columbia Street, Suite 1200
Portland, Oregon 97201-5843
voice: 503-223-8248 x715
voice: 800-788-1887 x715
fax:  503-223-8248
[hidden email]


-----Original Message-----
From: Daniel Robertson [mailto:[hidden email]]
Sent: Friday, June 13, 2008 7:28 AM
Subject: Re: Is there an easy way to lable the values of one variable with the values of an other?

I can think of a few reasons why the OPs request would be useful; this is a problem I've been thinking about as well but haven't found a solution to. To be clear, I understood the OPs request as finding an /automated/ way to assign value labels to one variable based on the associated values of another variable, assuming there is a one-to-one mapping between the values of the two variables.

Let me offer another example. Our newly implemented campus data system represents many types of categorical information by using two fields, a short code and a descriptor, and there is always a one-to-one mapping between codes and descriptors. Here's an example using Financial Aid Type:

  FA_CODE     FA_TYPE_DESCR
  "2"         "Loan/Work Replacing Grant"
  "L"         "Loan"
  "W"         "Work/Study"

The FA_CODE field is short and more convenient to use in coding -- e.g., typing "if(FA_TYPE EQ '2')" is for me less prone to error than typing "if(FA_TYPE_DESCR = 'Loan/Work Replacing Grant'')" -- but the Long Descriptor field is, well, much more descriptive and would be useful in tables and reports.

For parsimony's sake, it would be nice to retain the CODE variable but apply the associated values in the DESCRIPTOR variable as value labels to the CODE variable. New codes with their associated descriptions can be added to the source database at any time, which is why I am interested in deriving the value labels from the data anew each time I extract a datafile. AUTORECODE is a less-attractive option because I (and I think the OP as well) would like to retain the original code used in the source file.

I have a vague idea that this could be done by generating a table of code-descriptor pairs using a CTABLE command, access the table with OMS, and write a python macro to assign the descriptors as value labels to their associated codes. But I haven't gotten very far and am not sure this is even a reasonable approach.

Anyone else tried this or have any ideas?

Dan R.



ViAnn Beadle wrote:

> Why not just use Var3 in your analysis as a string variable? What do
> you intend to do with this variable?
>
> -----Original Message-----
> From: SPSSX(r) Discussion [mailto:[hidden email]] On Behalf
> Of Falcato Luis
> Sent: Friday, June 13, 2008 7:17 AM
> To: [hidden email]
> Subject: AW: Is there an easy way to lable the values of one variable
> with the values of an other?
>
> Hi,
>
> Because there are many many codes and this would need a very long val
> lab statement and a lot of writing...I' looking for a automated way to do it.
> -----Ursprüngliche Nachricht-----
> Von: [hidden email] [mailto:[hidden email]] Im
> Auftrag von Helmut Vorkauf
> Gesendet: Freitag, 13. Juni 2008 15:10
> An: Falcato Luis
> Betreff: Re: Is there an easy way to lable the values of one variable
> with the values of an other?
>
> why not just
> VALUE LABELS VAR2 'F11.2'  'Psychische und Verhaltensstörungen durch
> Opioide: Abhängigkeitssyndrom' 'F14.1' 'Psychische und
> Verhaltensstörungen durch Kokain: Schädlicher Gebrauch'
>
>
>
> On Fri, Jun 13, 2008 at 2:34 PM, Falcato Luis <[hidden email]> wrote:
> Dear SPSSers
>
> Is there an easy way to label the values of one variable with the
> values of an other?
>
> Example:
> The data file contains 3 variables. I would like to have the values of
> Var2 labeled with the strings stored in Var3.
>
> Var1            Var2            Var3
> CaseID  ICD-Code        verbatim diagnose
> 180             F11.2   Psychische und Verhaltensstörungen durch Opioide:
> Abhängigkeitssyndrom
> 2965            F11.2   Psychische und Verhaltensstörungen durch Opioide:
> Abhängigkeitssyndrom
> 2880            F14.1   Psychische und Verhaltensstörungen durch Kokain:
> Schädlicher Gebrauch
> ...
>
>
>
> Many thanks for your sugestions.
>
> Regards Luis
>
> Luis Manuel Falcato, lic. phil.
> Leiter Evaluation + Forschung
> ARUD Zürich
> Sihlhallenstrasse 30
> CH-8026 Zürich
> [hidden email]<mailto:[hidden email]>
> www.arud-zh.ch<http://www.arud-zh.ch>
> www.gain-zh.ch<http://www.gain-zh.ch>
>
> =====================
> To manage your subscription to SPSSX-L, send a message to
> [hidden email]<mailto:[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
>
>
>
> --
> Helmut Vorkauf
> e-mail [hidden email]
> tel ++41-(0)31-332 21 64
> mobile ++41-(0)79-622 88 03
> fax ++41-(0)31-560 45 31
>
>
>

--
Daniel Robertson
Senior Research and Planning Associate
Institutional Research and Planning
Cornell University / irp.cornell.edu

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

Variable length across SPSS versions

Matthew Reeder
Hi all,
&nbsp;
I'm currently running v.14 on my primary computer. I also run v.11.5 off of another computer. Version 11.5 restricts variable code lengths to 8 characters or less, while v.14 does not. Given that I run most of my analyses on v.14 and do some additional work on v.11.5, this can be somewhat inconvenient.
&nbsp;
In v.14, is there anyway for me to (temporarily) restrict the variable codes to a length of 8&nbsp;characters&nbsp;in the same way that v.11.5 does, so that I can know ahead of time, when working on an analysis on v.14, what the variable codes will be when I go to continue my analysis on v.11.5? In other words, is there a setting in v.14 to revert back to the 8-character limit, and have it then go and change all of the variables in the open dataset to that format?
&nbsp;
Thanks for any advice.
&nbsp;
&nbsp;
Best,
Matt

=====================
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: Variable length across SPSS versions

Peck, Jon
No.  Newer versions just accept longer names.  A 14 or later sav file, though, does present an 8-byte name to older versions.  If the true name is longer, it is just truncated if memory serves if that name would be unique; otherwise it is mangled into a unique name.  But, again if my memory is right, older version syntax will just ignore things after the first 8 bytes in syntax, so, subject to the uniqueness constraint, you might get away with using the long names in the old version.

Try this out, though.  My memory only goes back so far, and I don't have an old enough version installed to test this.

Regards,
Jon Peck

-----Original Message-----
From: SPSSX(r) Discussion [mailto:[hidden email]] On Behalf Of Matthew Reeder
Sent: Saturday, June 14, 2008 1:05 PM
To: [hidden email]
Subject: [SPSSX-L] Variable length across SPSS versions

Hi all,
&nbsp;
I'm currently running v.14 on my primary computer. I also run v.11.5 off of another computer. Version 11.5 restricts variable code lengths to 8 characters or less, while v.14 does not. Given that I run most of my analyses on v.14 and do some additional work on v.11.5, this can be somewhat inconvenient.
&nbsp;
In v.14, is there anyway for me to (temporarily) restrict the variable codes to a length of 8&nbsp;characters&nbsp;in the same way that v.11.5 does, so that I can know ahead of time, when working on an analysis on v.14, what the variable codes will be when I go to continue my analysis on v.11.5? In other words, is there a setting in v.14 to revert back to the 8-character limit, and have it then go and change all of the variables in the open dataset to that format?
&nbsp;
Thanks for any advice.
&nbsp;
&nbsp;
Best,
Matt

=====================
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: Variable length across SPSS versions

Matthew Reeder
Hey Jon,
&nbsp;
Thanks for the quick reply. I believe I see what you're saying - so long as the first 8 characters in the variable code are unique, 11.5 maintains those characters in the chopped-down variable code (so, if the original variable is aabbccdd_1234 in 14, it will&nbsp;appear as&nbsp;aabbccdd so long as this is unique in 11.5). Unfortunately, I often have multiple variables that manage to start with the same initial 8 characters, which 11.5 then it turns into the mangled mess of which you speak&nbsp;below. In reality,&nbsp;that's not a huge problem...I just go and save the current variable labels that are in the dataset into another file for reference, and then copy all of the variable codes (in 14) into the variable labels (so, for each variable, the label is the variable code). That way, when I get on 11.5, I can tell which variables are which simply by looking at the variable labels. The only area that remains problematic is finding that my
 syntax&nbsp;sometimes crashes unless I'm careful to change everything beforehand.
&nbsp;
Ehh well, just thought I'd check. Thanks again!
&nbsp;
&nbsp;
&nbsp;
Best,
Matt

--- On Sat, 6/14/08, Peck, Jon &lt;[hidden email]&gt; wrote:

From: Peck, Jon &lt;[hidden email]&gt;
Subject: RE: [SPSSX-L] Variable length across SPSS versions
To: [hidden email], [hidden email]
Date: Saturday, June 14, 2008, 4:08 PM

No.  Newer versions just accept longer names.  A 14 or later sav file, though,
does present an 8-byte name to older versions.  If the true name is longer, it
is just truncated if memory serves if that name would be unique; otherwise it
is mangled into a unique name.  But, again if my memory is right, older version
syntax will just ignore things after the first 8 bytes in syntax, so, subject to
the uniqueness constraint, you might get away with using the long names in the
old version.

Try this out, though.  My memory only goes back so far, and I don't have an
old enough version installed to test this.

Regards,
Jon Peck

-----Original Message-----
From: SPSSX(r) Discussion [mailto:[hidden email]] On Behalf Of
Matthew Reeder
Sent: Saturday, June 14, 2008 1:05 PM
To: [hidden email]
Subject: [SPSSX-L] Variable length across SPSS versions

Hi all,
&amp;nbsp;
I'm currently running v.14 on my primary computer. I also run v.11.5 off of
another computer. Version 11.5 restricts variable code lengths to 8 characters
or less, while v.14 does not. Given that I run most of my analyses on v.14 and
do some additional work on v.11.5, this can be somewhat inconvenient.
&amp;nbsp;
In v.14, is there anyway for me to (temporarily) restrict the variable codes to
a length of 8&amp;nbsp;characters&amp;nbsp;in the same way that v.11.5 does, so
that I can know ahead of time, when working on an analysis on v.14, what the
variable codes will be when I go to continue my analysis on v.11.5? In other
words, is there a setting in v.14 to revert back to the 8-character limit, and
have it then go and change all of the variables in the open dataset to that
format?
&amp;nbsp;
Thanks for any advice.
&amp;nbsp;
&amp;nbsp;
Best,
Matt

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