creating new variable from old variable with value labels copied

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

creating new variable from old variable with value labels copied

msherman
Dear List: Is there a way to create a new variable from an old variable but carrying over the value labels and even the variable labels other than copying and pasting within variable view. thanks, martin sherman
Reply | Threaded
Open this post in threaded view
|

Re: creating new variable from old variable with value labels copied

John Norton
Hi Martin,
 
The best way I know of is to use the compute statement to create the new variable, and then apply the dictionary information from the old variable to the new.  If you're using the GUI, you can easily copy the variable attributes from the old/source variable, then paste them to the newly created variable in the Variable View.
 
HTH,
 
JN
 
John Norton
Biostatistician
Oncology Institute
Loyola University Medical Center
 
(708) 327-3095
[hidden email]
 
"Absence of evidence
      is not evidence of absence"


>>> Martin Sherman <[hidden email]> 2/21/2007 7:24:01 AM >>>

Dear List: Is there a way to create a new variable from an old variable but carrying over the value labels and even the variable labels other than copying and pasting within variable view. thanks, martin sherman
Reply | Threaded
Open this post in threaded view
|

Re: creating new variable from old variable with value labels copied

John Norton
In reply to this post by msherman
Hi List,
 
A followup to my last post, which may have lack some specifics.
 
One can create a new variable from an existing or source variable simply be using the COMPUTE statement (or the Compute menu item under the Transform menu), thus:
 
COMPUTE new_var - old_var.
 
This will unfortunately not also carry over the variable labels, value labels, formats and other definitions.  To do so, you could execute the following command (which applies the variable and value labels only, but which can be edited to include other formatting commands as well)..
 
APPLY DICTIONARY
  /FROM *
  /SOURCE VARIABLES =  old_var
  /TARGET VARIABLES =  new_var
  /FILEINFO
  /VARINFO VALLABELS = REPLACE VARLABEL .

I was able to paste the above commands from the Copy Data Properties menu item under the Data menu.  In that dialog you can specify that you want the variable definitions copied from a variable in the working or an external data set.  You can also specify several source and several target variables.  Following through the prompts in the Copy Data Properties Wizard will assist with applying the data definitions, or (as I did above) pasting the command for later reference and use.
 
I hope this expands more on my previous note.
 
JN
 
John Norton
Biostatistician
Oncology Institute
Loyola University Medical Center
 
(708) 327-3095
[hidden email]
 
"Absence of evidence
      is not evidence of absence"


>>> Martin Sherman <[hidden email]> 2/21/2007 7:24:01 AM >>>

Dear List: Is there a way to create a new variable from an old variable but carrying over the value labels and even the variable labels other than copying and pasting within variable view. thanks, martin sherman
Reply | Threaded
Open this post in threaded view
|

Re: creating new variable from old variable with value labels copied

Peck, Jon
In reply to this post by msherman
Take a look at APPLY DICTIONARY (known as Copy Data Properties in the user interface).

-----Original Message-----
From: SPSSX(r) Discussion [mailto:[hidden email]] On Behalf Of Martin Sherman
Sent: Wednesday, February 21, 2007 7:24 AM
To: [hidden email]
Subject: [SPSSX-L] creating new variable from old variable with value labels copied

Dear List: Is there a way to create a new variable from an old variable but carrying over the value labels and even the variable labels other than copying and pasting within variable view. thanks, martin sherman