05-27-2014 11:55 AM
Basically, I have a large SAS assignment which I know how to do by hand, but I'm sure there are lots of useful shortcuts that I don't know about which could make it less cumbersome!
I have a Word document outlining about a thousand values that have been divided into 16 categories. I also have a SAS dataset in which each row can contain up to 10 variables containing the values that have been categorized in the Word document.
The only way I can think to do this is to code by hand:
If var1 in (abc, def, ghi, jkl) then category1=1;
else if var1 in (mno, pqr, stu, vwx) then category1=2;
else if var1 in (zzz, zyx, wvu, tsr) then category1=16;
if var2 in (abc, def, ghi, jkl) then category2=1;
else if var2 in (mno, pqr, stu, vwx) then category2=2;
As you can see, this gets very cumbersome very quickly, as I have 10 vars containing the values and 16 categories. Any shortcuts would be much appreciated!
05-27-2014 12:17 PM
You'd have to provide more detailed examples for more detailed help. But generally, if its categorizing or recoding, look at a merge, hash or proc format instead of multiple if/then statements.
If you're doing the same thing across a whole bunch of variables consider an array as well.
05-27-2014 01:11 PM
Depending on the structure and contents of your Word document you may be able to use it to make a dataset that will create formats.