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

Don't miss out on SAS Innovate - Register now for the FREE Livestream!

Can't make it to Vegas? No problem! Watch our general sessions LIVE or on-demand starting April 17th. Hear from SAS execs, best-selling author Adam Grant, Hot Ones host Sean Evans, top tech journalist Kara Swisher, AI expert Cassie Kozyrkov, and the mind-blowing dance crew iLuminate! Plus, get access to over 20 breakout sessions.

 

Register now!

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.

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
  • 6 replies
  • 1154 views
  • 2 likes
  • 5 in conversation