BookmarkSubscribeRSS Feed
🔒 This topic is solved and locked. Need further help from the community? Please sign in and ask a new question.
myboys2
Fluorite | Level 6

 

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

1 ACCEPTED SOLUTION

Accepted Solutions
Astounding
PROC Star

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;

 

 

View solution in original post

6 REPLIES 6
Astounding
PROC Star

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;

 

 

Steelers_In_DC
Barite | Level 11

Add an options command before your proc freq.

 

options obs=100;

Reeza
Super User

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;

PGStats
Opal | Level 21

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.

PG
myboys2
Fluorite | Level 6

this is perfect - thank you:)

myboys2
Fluorite | Level 6

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?

SAS Innovate 2025: Save the Date

 SAS Innovate 2025 is scheduled for May 6-9 in Orlando, FL. Sign up to be first to learn about the agenda and registration!

Save the date!

How to Concatenate Values

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.

SAS Training: Just a Click Away

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

Browse our catalog!

Discussion stats
  • 6 replies
  • 1742 views
  • 2 likes
  • 5 in conversation