11-30-2013 01:26 PM
I merged two data files from the CDC's NHIS 2012 data files ( the adult and disability files). The merge was successful however I cannot do anything with the merged data file to edit the data. I can print out the data and run freqs and means but I can not change any of the variables. For example, when I try to recode a variable or create a new variable, SAS deletes all of the variables in the data set and or says that the variable is uninitialized. If anyone can lend a hand I would greatly appreciate it.
11-30-2013 06:36 PM
thank so much for replying ....however i did use the set command to set the permanent merged file i created to a temporary file. This is what I had in my code:
LIBNAME nhisproj "P:\Project";
KEEP SEX RACERPI2 AFD_FLG DOINGLWA AGE_P BMI
FLA1AR MOB_2R MOB_3F
AFLHCA18 AFLHCA17 UB_SS
AFLHCA13 ALHCA14A AFLHCA15; /*Subset variables*/
PROC PRINT DATA=NHISproj.NHIS2012perm; /*Print the small subset*/
and this works fine but then when i try to do anything with the variables like recode them or create new variables it does not work.
11-30-2013 06:50 PM
The KEEP statement applies to the output data set (nhisproj.NHIS2012perm). So make sure that any new variable you create is listed in the KEEP statement.
I suggest that you omit the KEEP statement while you're developing code.
12-06-2013 04:05 PM
You have created a permanent SAS file called NHISproj.NHIS2012perm.
Make sure when you perform data transformation you assign the correct permanent SAS path:
< transformation code >;
12-06-2013 05:37 PM
I recommend that you NOT reuse the input and output data for this if you are recoding actual values of original variables as you'll end up having to redownload/combine data if you make an error.
I have seen this done to a data set reducing the number of categories such as:
if x>4 then x=4;
Else if x in (3,4) then x=2;
else if x =2 then x=0;
While modifying code affecting other variables and making changes, the value of X eventually becomes 0 or 1 when it should be 0,1,2 or 4.
Better is to
Also, Formats are often much more effecient for many grouping tasks than creating new variables.