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 .

sas-innovate-2024.png

Don't miss out on SAS Innovate - Register now for the FREE Livestream!

Can't make it to Vegas? No problem! Watch our general sessions LIVE or on-demand starting April 17th. Hear from SAS execs, best-selling author Adam Grant, Hot Ones host Sean Evans, top tech journalist Kara Swisher, AI expert Cassie Kozyrkov, and the mind-blowing dance crew iLuminate! Plus, get access to over 20 breakout sessions.

 

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.

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
  • 20 replies
  • 2559 views
  • 8 likes
  • 8 in conversation