Reputation: 11
I want to merge SPSS datasets from different years. Problem is that some variables have added new labels over time (e.g. the labels for "year" are specific for every dataset). So when I combine them, it does not integrate the labels from the added dataset. Do you know how it's possible to accomplish a merge of the labels as well?
Edit: For clarification, the datasets do have their own labels each, so later studies do not have the labels of older studies included. For Example:
Dataset 2020
202001 = January 2020
202002 = February 2020
.
.
.
202012 = December 2020
Dataset 2021
202101 = January 2021
202102 = February 2010
.
.
.
202112 = December 2021
... and so on. So very easy labeling for each dataset respectively year. Now I want to merge the files into one and have the labels from all datasets combined.
Upvotes: 1
Views: 162
Reputation: 11310
Whenever you want to add a new file to your "stack" of data files you can go this way to add value labels from the new file to the existing one:
dataset name stackedData. /* just naming the originan/full/stacked data.
get file="path\file.sav".
dataset name newdata.
* the following will capture value labels from the new file into a table.
DATASET DECLARE vals.
OMS /SELECT TABLES /IF COMMANDS=['File Information'] SUBTYPES=['Variable Values']
/DESTINATION FORMAT=SAV OUTFILE='vals'.
display dictionary.
omsend.
dataset activate vals.
* Now we create a syntax to add all the value labels of this file to another one.
string cmd(a50).
compute cmd=concat("add value labels ",var1, " ", string(var2,f2), ' "', replace(label, "(Void)", ""), '".').
* at this point you can select if you only want to add value labels from specific variables and not all.
select if any(var1, "yearmonth", "somevar", "anothervar").
write out="c:\users\eli\remove void.sps" /cmd.
exe.
* the syntax is created, we go back to the original data and insert it.
dataset activate stackedData.
insert file="c:\users\eli\remove void.sps".
* now we can add the new data file.
add files /file=* /file=newdata.
Upvotes: 0