03-09-2015 05:51 AM
There are lots of data for years.(from 1990 to 2015)
A survey is done every 6 months.
Different options were used same variables for each period
I want to get a table with proc tabulate for any variables, I have to use the separately for each period and each year then combine output.
I want to combine/append all these data sets.
Variable names are the same for each period/years but different options for the years.
This format used between 1990-2000
2='Neither nor unsatisfied';
This format used between 2000-2005
13='Neither nor unsatisfied'
45='Not satisfied at all'
This format used from 2005
03='Neither nor unsatisfied'
05='Not satisfied at all'
when using proc tabulate use the following format for years less then 2000.
is it possible?
I would like to summary tables combine the data with a single proc tabulate.
03-09-2015 08:51 AM
If it were me, I would change the data. For variable 1, if the answer was 1 and the survey year was 1991, I would change the value from 1 to 199101. You end up with a six-digit value, and just a single format would be needed. After that, PROC TABULATE is easy.
03-09-2015 11:15 AM
If you didn't have multiple meanings for the same value: 1 in 1990 with a different meaning in 2005 you could have just modified the format as you multiple values can map to the same formatted value and Proc Tabulate will use the formatted value (though the display order might be an issue sometimes).
But if you have many variables doing this I agree that Astounding's approach I likely a better solution in the long run. It will have the added benefit that values from a later dataset wouldn't have the values of the format and the appearance of the "raw" value would be a reminder for validation and update of the format for combined data.
Another option would be to create Text versions of the variables using the format for the appropriate year and then combining the data and using only the text values. Which could seriously complicate appearance orders in Tabulate output.
03-09-2015 12:37 PM
Is your variable character or numeric? If your variable is character you don't appear to have an overlap.
The last format looks character but the first two look to be numeric.
Otherwise as Astounding has mentioned you should map all variables to one system.
03-10-2015 04:27 AM
There are differences as of year ,As can be understood from the format.
Some years the characters, some years numeric.
take based on the format of the final year(2015) of the past year I have to edit accordingly.
but there are different codes.
should I prepare most wide format which included the whole years?
Is there something like this?
if year=1991 then use format...
03-10-2015 10:32 AM
If you are going to combine the data into a single dataset you will need to pick whether the variable is going to be numeric or character.
Formats are not conditional. A variable may only have one format associated at a given time.
03-10-2015 01:22 PM
I would recommend creating a new numeric variable, the numeric variable would allow the results to sort correctly for display in proc tabulate whereas the character variable would sort alphabetically.
0, 11='Very satisfied'
2, 13='Neither nor unsatisfied'
45='Not satisfied at all'
IN THE DATASTEP:
if year=2005 then do;
if variable_orig='01' then variable_new=11;
else if variable_orig='02' then variable_new=12;
else if variable_orig='03' then variable_new=13;
else if variable_orig='04' then variable_new=14;
else if variable_orig='05' then variable_new=15;
else if variable_orig='06' then variable_new=99;
format variable_new satisfaction_fmt.;
03-10-2015 03:37 PM
You could use the inputc for converting the data according to different years. SAS(R) 9.4 Functions and CALL Routines: Reference, Third Edition
This is possible because the used format is not a static one but can be a variable deduced from in your case years.
You could define a format using also the fcmp options Base SAS(R) 9.4 Procedures Guide, Third Edition
The FCMP approach has some limitations as not being of the same kind (compatible) with classic SAS functions Base SAS(R) 9.4 Procedures Guide, Third Edition The report procedures is supporting it.