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

The 2025 SAS Hackathon has begun!

It's finally time to hack! Remember to visit the SAS Hacker's Hub regularly for news and updates.

Latest Updates

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
  • 5263 views
  • 9 likes
  • 8 in conversation