BookmarkSubscribeRSS Feed
ddutton325
Fluorite | Level 6

HI y'all,

I know that there is a way to get either or both of PROC MEANS or PROC SUMMARY to give me a simple count of a character variable by a couple of CLASS variables.  I am pretty sure that before PROC MEANS and PROC SUMMARY basically became one and the same, that SUMMARY supported that, while MEANS did not.  but so far, my attempts to get this elusive number have been unsuccessful.  

 

Does anyone know how to do this?  I really do not want to resort to DATA step or PROC SQL.

thanks,

Donna

 

4 REPLIES 4
PaigeMiller
Diamond | Level 26

PROC FREQ is the tool you want. It should be your first choice whenever you have to count things.

 

 

 

--
Paige Miller
Tom
Super User Tom
Super User

Syntax should be the same. 

proc summary data=sashelp.class;
 class sex ;
 output out=want ;
run;
proc print;
run;

Tom_0-1728613033009.png

 

Bala_Saladi
Fluorite | Level 6

Try to get frequency through proc means:-

 

proc means data=sashelp.class n;
class name sex;
output out=means_out (DROP=_type_ _freq_ );

data means_out;
set means_out;
where _STAT_='N';
run;
proc print;
run;

 

Bala_Saladi_0-1728768466473.png

 

Rick_SAS
SAS Super FREQ

Use the TABLE statement in PROC FREQ. You can add the OUT= option if you need the counts in a data set.

proc freq data=sashelp.class;
   table sex / out=FreqOut;
run;

Rick_SAS_0-1728811581632.png

 

hackathon24-white-horiz.png

The 2025 SAS Hackathon Kicks Off on June 11!

Watch the live Hackathon Kickoff to get all the essential information about the SAS Hackathon—including how to join, how to participate, and expert tips for success.

YouTube LinkedIn

What is Bayesian Analysis?

Learn the difference between classical and Bayesian statistical approaches and see a few PROC examples to perform Bayesian analysis in this video.

Find more tutorials on the SAS Users YouTube channel.

SAS Training: Just a Click Away

 Ready to level-up your skills? Choose your own adventure.

Browse our catalog!

Discussion stats
  • 4 replies
  • 1016 views
  • 0 likes
  • 5 in conversation