DATA Step, Macro, Functions and more

proc freq getting only first row

Accepted Solution Solved
Reply
Contributor
Posts: 39
Accepted Solution

proc freq getting only first row

below example how to get only first row in output

proc freq data=sashelp.class;
tables age;run;

need only highlited in output window instead of getting all

Untitled.png


Accepted Solutions
Solution
‎03-22-2017 01:54 AM
Contributor
Posts: 56

Re: proc freq getting only first row

proc freq data=sashelp.class(where=(age=11));
tables age;run;

View solution in original post


All Replies
Super User
Posts: 5,083

Re: proc freq getting only first row

PROC FREQ prints the whole table (or alternatively, none of the table).  But you can work around that if you find a slightly different report format satisfactory:

 

proc freq data=have;

tables age / noprint out=counts;

run;

 

proc print data=counts (obs=1);

run;

Solution
‎03-22-2017 01:54 AM
Contributor
Posts: 56

Re: proc freq getting only first row

proc freq data=sashelp.class(where=(age=11));
tables age;run;
Respected Advisor
Posts: 4,649

Re: proc freq getting only first row

Another way:

 

proc freq data=sashelp.class noprint;
tables age / out=counts;
run;

proc sql;
create table firstCount as
select * from counts
having age=min(age);
select * from firstCount;
quit;
PG
☑ This topic is SOLVED.

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

Discussion stats
  • 3 replies
  • 136 views
  • 0 likes
  • 4 in conversation