BookmarkSubscribeRSS Feed
🔒 This topic is solved and locked. Need further help from the community? Please sign in and ask a new question.
SuryaKiran
Meteorite | Level 14

Just a simple code that output depending on percentage.

proc sql;

select count(*) Into: OBSCOUNT

from sashelp.class;

quit;

%let pct=80 ; /* Percentage of observation to output */

data test1;

set sashelp.class ;

if _N_=INT((&pct*&obscount)/100)+1 then stop;

run;

 

Thanks,
Suryakiran
Reeza
Super User

@SuryaKiran That's not a random selection - it selects the top N records. 

Ksharp
Super User

Yeah. @data_null__ ,John King got the point.

If you really want DELETE.

 

 

 

%let delete_freq=12;

proc surveyselect data=sashelp.cars group=100 out=want;
run;
data want;
 set want;
 if groupid le &delete_freq then delete;
 drop groupid;
run;

 

 

RTelang
Fluorite | Level 6
@Ksharp lil brief explanation of code wats it doing...?
RW9
Diamond | Level 26 RW9
Diamond | Level 26

There is a thing called Base SAS - it is the programming language your are using, even if you insist on wrapping the whole system in macro code.  It is a well documented fully functional languange, and you can find all the documentation online at SAS:

https://support.sas.com/documentation/cdl/en/statug/63033/HTML/default/viewer.htm#surveyselect_toc.h...

Ksharp
Super User

proc surveyselect group=100  is randomly assigning 100 group to your data. data step is delete the data which has group <= 12.

I think you should take John King 's advice ( samplerate=0.8) , data step is totally redundant .

hackathon24-white-horiz.png

2025 SAS Hackathon: There is still time!

Good news: We've extended SAS Hackathon registration until Sept. 12, so you still have time to be part of our biggest event yet – our five-year anniversary!

Register Now

How to Concatenate Values

Learn how use the CAT functions in SAS to join values from multiple variables into a single value.

Find more tutorials on the SAS Users YouTube channel.

SAS Training: Just a Click Away

 Ready to level-up your skills? Choose your own adventure.

Browse our catalog!

Discussion stats
  • 20 replies
  • 5160 views
  • 9 likes
  • 8 in conversation