Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Need help with sas printing procedure...

Status
Not open for further replies.

sasNoodle

Technical User
Nov 13, 2008
2
US
Hi everyone, I'm trying to write a proc print that prints to the output screen every 100,000th observation. Is there any easy way to do this?
 
I can't see a way to do this without subsetting the data first. Something like the following perhaps... Data large is a dummy dataset of 1 million records and data small is taking a record every 100,000. If you have a large dataset this may take a while.
HTH

Code:
data large;
do i=1 to 1000000;
   output;
end;
run;

data small;
set large;
if ^mod(_n_,100000);
run;
proc print;run;
 
Hi - I think you need to create an observation number on your source dataset before doing the proc print. Try a variation of this:

Code:
data xx; set whatever;
	zz=_n_;
run;


proc print data=xx;
where mod(zz,100000)=0;
run;
 
Actually, thinking about it, a simpler way to get the same result would be to use proc sql, (no proc print required as sql output is automatically printed) - try this...

Code:
proc sql;
	select 
	variable1, variable2, etc
	from your_dataset
	where mod(monotonic(),100000)=0
;
quit;
 
Thanks krispi and kdt82 for your help. This worked!!
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top