Desktop productivity for business analysts and programmers

How to get number of observation printted in saslist

Reply
Contributor
Posts: 34

How to get number of observation printted in saslist

Hi,
i would like to store the number observation printed by PROC PRINT into a macro variable. Could you please let me know how will i get it. For Ex, i want to store the number of OBS for below statement.

PROC PRINT DATA=DATA1; WHERE CUST_NAME ='PRABA';RUN;
SAS Super FREQ
Posts: 8,719

Re: How to get number of observation printted in saslist

Hi:
See this previous forum posting for an idea of how macro variable creation works in general:
http://support.sas.com/forums/thread.jspa?messageID=8249‹

and then study this modification of that previous program:
[pre]
proc sql;
select count(name) into :cntobs
from sashelp.class
where age ge 15;
quit;

%let cntobs = &cntobs;
%put cntobs= &cntobs is the number of obs in SASHELP.CLASS;
%put where age was greater than or equal to 15;

ods listing;
proc print data=sashelp.class N;
title "Students who meet the criteria: &cntobs";
where age ge 15;
run;
[/pre]
which produces this output:
[pre]
Students who meet the criteria: 5

Obs Name Sex Age Height Weight

8 Janet F 15 62.5 112.5
14 Mary F 15 66.5 112.0
15 Philip M 16 72.0 150.0
17 Ronald M 15 67.0 133.0
19 William M 15 66.5 112.0

N = 5

[/pre]

Note how the number from &CNTOBS used in the title is equal to the N= that is put into the PROC PRINT (after the detail listing).

cynthia
Ask a Question
Discussion stats
  • 1 reply
  • 97 views
  • 0 likes
  • 2 in conversation