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 am printing a proc freq via  pdf and I was wondering if there is a way to only print 200  observations in a proc freq?

Thank you

1 ACCEPTED SOLUTION

Accepted Solutions
ballardw
Super User

Since your subject line says "top frequencies" what I would suggest would be to run proc freq with no print and create an output data set and then print that with the OBS= dataset option to print the top 200.

Something like:

proc freq data=have noprint order=freq;

tables variable /out= want;

run;

proc print data=want (obs=200) noobs ;

run;

View solution in original post

3 REPLIES 3
ballardw
Super User

Since your subject line says "top frequencies" what I would suggest would be to run proc freq with no print and create an output data set and then print that with the OBS= dataset option to print the top 200.

Something like:

proc freq data=have noprint order=freq;

tables variable /out= want;

run;

proc print data=want (obs=200) noobs ;

run;

Rick_SAS
SAS Super FREQ

I assume you want only the Top 200 groups, ordered by frequency. See the PROC FREQ discussion at https://communities.sas.com/thread/82076

Basically you can use ORDER=FREQ and suppress output by using the NOPRINT option, then use the OUT= option on the TABLES statemnt to write the frequencies to a data set. Then use PROC PRINT with OBS=200.

myboys2
Fluorite | Level 6

Thank you and what you provided worked however I have 10 variable is my freq that I want to print.  When I do the out= it only prints the variable in front of the out - which happens to be the last variable.

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
  • 3 replies
  • 1764 views
  • 3 likes
  • 3 in conversation