BookmarkSubscribeRSS Feed
DPraba79
Calcite | Level 5
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;
1 REPLY 1
Cynthia_sas
SAS Super FREQ
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

sas-innovate-2024.png

Join us for SAS Innovate April 16-19 at the Aria in Las Vegas. Bring the team and save big with our group pricing for a limited time only.

Pre-conference courses and tutorials are filling up fast and are always a sellout. Register today to reserve your seat.

 

Register now!

SAS Enterprise Guide vs. SAS Studio

What’s the difference between SAS Enterprise Guide and SAS Studio? How are they similar? Just ask SAS’ Danny Modlin.

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
  • 1 reply
  • 556 views
  • 0 likes
  • 2 in conversation