BookmarkSubscribeRSS Feed
lincolnst
Calcite | Level 5

Capture.PNG

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.

Capture1.PNG

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.

2 REPLIES 2
Reeza
Super User

If you can restructure your data I'd strongly recommend that option, via a PROC TRANSPOSE and then a PROC FREQ. 

ballardw
Super User

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-2024.png

Available on demand!

Missed SAS Innovate Las Vegas? Watch all the action for free! View the keynotes, general sessions and 22 breakouts on demand.

 

Register now!

SAS Enterprise Guide vs. SAS Studio

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.

Click image to register for webinarClick image to register for webinar

Classroom Training Available!

Select SAS Training centers are offering in-person courses. View upcoming courses for:

View all other training opportunities.

Discussion stats
  • 2 replies
  • 2494 views
  • 0 likes
  • 3 in conversation