Quantcast

Creating SPSS data file with master codes instead of original SPSS codes

classic Classic list List threaded Threaded
2 messages Options
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Creating SPSS data file with master codes instead of original SPSS codes

snehachidire
1. We have SPSS numeric data file with value labels for 2016 wave 4.
2. And a Master value labels list in excel (Like SPSS display dictionary) for all variables including previous years/waves from 2010 to 2016(including W4).

Though the codes are different, the label in SPSS data file will exist in the master list.

For each variable in SPSS data file it has to check the corresponding Variable & label in Master labels list and assign master codes instead of the original SPSS code.
Like wise it should do for all the 2016 wave 4 variables and create one new SPSS data file with new codes from master list.

In SPSS we can do by recoding each variable, but it is a huge data with so many variables (~900). So without recoding procedure any other solution in SPSS , python or R is fine.

For Ex: SPSS data file has two variables with corresponding value label as shown in the attached image



Thanks in advance,
Sneha

Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: Creating SPSS data file with master codes instead of original SPSS codes

David Marso
Administrator
Not writing your code but a general idea.
See DO REPEAT, VALUELABEL function, VARSTOCASES, MATCH FILES, CASETOVARS, APPLY DICTIONARY.

General idea, UNTESTED, should do most of the heavy lifting.
------------------------------------

DO REPEAT source=num1 TO num900 / result=label1 TO label900.
STRING result(A100).
COMPUTE result=VALUELABEL(source).
END REPEAT.
COMPUTE ID=$CASENUM.

VARSTOCASES
  / MAKE source FROM num1 TO num900
  / MAKE label FROM label1 TO label900
  / INDEX=varname(source ).

SORT CASES BY varname label.
MATCH FILES /FILE * / TABLE = masterfile / BY varname label.
COMPUTE newvar=valueInFirstColumnOfMasterFile.
SORT CASES BY ID .

DELETE VARIABLES source label
CASESTOVARS /INDEX=varname.
APPLY DICTIONARY /FILE masterfile .

HTH.

snehachidire wrote
1. We have SPSS numeric data file with value labels for 2016 wave 4.
2. And a Master value labels list in excel (Like SPSS display dictionary) for all variables including previous years/waves from 2010 to 2016(including W4).

Though the codes are different, the label in SPSS data file will exist in the master list.

For each variable in SPSS data file it has to check the corresponding Variable & label in Master labels list and assign master codes instead of the original SPSS code.
Like wise it should do for all the 2016 wave 4 variables and create one new SPSS data file with new codes from master list.

In SPSS we can do by recoding each variable, but it is a huge data with so many variables (~900). So without recoding procedure any other solution in SPSS , python or R is fine.

For Ex: SPSS data file has two variables with corresponding value label as shown in the attached image



Thanks in advance,
Sneha
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?"
Loading...