Reputation: 1
I have 24 columns that list a code (code1, code2, code3 etc). I need to calculate a total frequency of codes from all 24 columns (from greatest to least). I tried creating separate files for each and then doing a proc freq but it only used that last file entered.
Upvotes: 0
Views: 68
Reputation: 12465
There are many ways to skin this beast. I would use an array in a Data Step to create 1 column out of 24. Then do what you will with it (PROC FREQ, or whatever).
This assumes your 24 columns are named, col1, col2, ... , col24.
data want;
set have;
array cols[24] col1 - col24; /*here list your columns*/
format code $32.; /*change size as needed*/
do i=1 to 24;
code = cols[i];
output;
end;
drop i col1 - col24; /*put your unneeded column names here*/
run;
Upvotes: 2