i only want to view/print 100 observations in a proc freq. I am just looking for 100 obs even if I am reading in 1 millon records
I am currently doing the following
proc freq data=a order=freq
tables ssn customer_id test_name/nocum nopercent;
Thank you
PROC FREQ does not support this. You can work around it, by creating output data sets. However, your program becomes longer because (a) you need an output data set for each table, and (b) you then have to print as a separate step. For example:
proc freq data=a order=freq;
tables ssn / noprint out=ssn_counts (keep=ssn count);
tables customer_id / noprint out=custid_counts (keep=customer_id count);
run;
proc print data=ssn_counts (obs=100);
run;
proc print data=custid_counts (obs=100);
run;
PROC FREQ does not support this. You can work around it, by creating output data sets. However, your program becomes longer because (a) you need an output data set for each table, and (b) you then have to print as a separate step. For example:
proc freq data=a order=freq;
tables ssn / noprint out=ssn_counts (keep=ssn count);
tables customer_id / noprint out=custid_counts (keep=customer_id count);
run;
proc print data=ssn_counts (obs=100);
run;
proc print data=custid_counts (obs=100);
run;
Add an options command before your proc freq.
options obs=100;
1. Are you looking for the top 100 records
2. Are you looking for sample output to test a program by limiting analysis?
If 1, then there's not an easy way.
If 2, then use either option obs=100; to limit all processing to 100 observations or the data set option obs=100 to limit the data input to proc freq directly, sample code below.
proc freq data=a (obs=100) order=freq
tables ssn customer_id test_name/nocum nopercent;
I think this might be a legitmate use of undocumented function monotonic()
proc freq data=sashelp.heart noprint;
table ageAtStart / out=ageFreq(where=(monotonic() <= 10));
run;
proc print data=ageFreq; run;
It works with order=freq as well.
this is perfect - thank you:)
Thank you i am also trying to remove the percent column by using the nopercent option however the few areas I have used it is not working. Any ideas?
Are you ready for the spotlight? We're accepting content ideas for SAS Innovate 2025 to be held May 6-9 in Orlando, FL. The call is open until September 25. Read more here about why you should contribute and what is in it for you!
Learn how use the CAT functions in SAS to join values from multiple variables into a single value.
Find more tutorials on the SAS Users YouTube channel.