proc freq

Accepted Solution Solved
Reply
Occasional Contributor
Posts: 18
Accepted Solution

proc freq

 

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


Accepted Solutions
Solution
‎01-13-2016 12:46 PM
Respected Advisor
Posts: 4,980

Re: proc freq

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


All Replies
Solution
‎01-13-2016 12:46 PM
Respected Advisor
Posts: 4,980

Re: proc freq

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;

 

 

Valued Guide
Posts: 854

Re: proc freq

Add an options command before your proc freq.

 

options obs=100;

Grand Advisor
Posts: 17,360

Re: proc freq

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;

Respected Advisor
Posts: 4,608

Re: proc freq

[ Edited ]

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
Occasional Contributor
Posts: 18

Re: proc freq

this is perfect - thank youSmiley Happy

Occasional Contributor
Posts: 18

Re: proc freq

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?

☑ This topic is SOLVED.

Need further help from the community? Please ask a new question.

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