Here are the Column names of our data. I am trying to make a frequency table that has LASTNAME as one column and the frequency of the amount of times that same LASTNAME appears in columns COMMMEM1-COMMMEM5 throughout the whole list of data.
Here is what I have tried.
data Comm;
infile "/home/lincolnstoebner0/SAS/COMMITTEEDATA.csv" dsd;
input LASTNAME : $20.
COMMMEM1 : $20.
COMMMEM2 : $20.
COMMMEM3 : $20.
COMMMEM4 : $20.
COMMMEM5 : $20.;
run;
proc freq data=Comm;
tables COMMMEM1-COMMMEM5 /out=want(drop=percent);
run;
And here is the output continuing on down in separate freq tables through COMMMEM5.
I am trying to get a one freq table with all the variables instead of 5 different freq tables for each variable. I believe this requires an array but am not able to figure out the code needed for the array.
If you can restructure your data I'd strongly recommend that option, via a PROC TRANSPOSE and then a PROC FREQ.
You don't say what you want in your table or what the table would look like. Or do you want the data set (your existing code only creates data for the last variable).
Perhaps other procedures may help:
proc tabulate data =comm;
class COMMMEM1 COMMMEM2 COMMMEM3 COMMMEM4 COMMMEM5 ;
table COMMMEM1 COMMMEM2 COMMMEM3 COMMMEM4 COMMMEM5 ,
n
;
run;
If you want a data set you'll have to show us what you want that data set to look like.
SAS Innovate 2025 is scheduled for May 6-9 in Orlando, FL. Sign up to be first to learn about the agenda and registration!
What’s the difference between SAS Enterprise Guide and SAS Studio? How are they similar? Just ask SAS’ Danny Modlin.
Find more tutorials on the SAS Users YouTube channel.
Ready to level-up your skills? Choose your own adventure.