mbrookz
mbrookz

Reputation: 35

Is there a way to get SAS to only print the first 10 rows of a frequency table?

I'm using proc freq in a Jupyter notebook but I don't want all the rows in the resulting frequency table to be displayed, only the first 10. I tried using (obs=10) but that just prints a frequency table using the first 10 observations in the data, which is not what I want.

Upvotes: 1

Views: 2715

Answers (1)

Joe
Joe

Reputation: 63424

Not directly from PROC FREQ. You can do it in two steps:

  1. PROC FREQ, but don't print the output; instead, send it to a table with OUT=
  2. PROC PRINT or PROC REPORT the table, using OBS= to limit it.

One example:

proc freq data=sashelp.cars;
tables make;
run;

becomes

proc freq data=sashelp.cars noprint;
tables make/out=tbl_make;
run;

proc print data=tbl_make(obs=10) noobs;
run;

One highly recommended option is to add the order=freq option to the proc freq statement as usually the higher frequencies are what you're interested in.

Upvotes: 1

Related Questions