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

How to split the data into three randoms sets: 60% in a building set, %10 in a test set and 30% in a validation set.

1 ACCEPTED SOLUTION

Accepted Solutions
PGStats
Opal | Level 21

You can use the GROUPS= option in proc surveyselect. You must provide the exact set sizes of calculate them like this:

 

proc sql;
select 
    round(0.6*count(*)) as n1,
    round(0.1*count(*)) as n2,
    count(*) - calculated n1 - calculated n2 as n3
into :n1, :n2, :n3
from sashelp.class;
quit;

proc surveyselect data=sashelp.class groups=(&n1 &n2 &n3) out=samples;
run;

 

 

PG

View solution in original post

4 REPLIES 4
PGStats
Opal | Level 21

You can use the GROUPS= option in proc surveyselect. You must provide the exact set sizes of calculate them like this:

 

proc sql;
select 
    round(0.6*count(*)) as n1,
    round(0.1*count(*)) as n2,
    count(*) - calculated n1 - calculated n2 as n3
into :n1, :n2, :n3
from sashelp.class;
quit;

proc surveyselect data=sashelp.class groups=(&n1 &n2 &n3) out=samples;
run;

 

 

PG
Greeshma
Fluorite | Level 6
Thank you, that helped.
Ksharp
Super User
data train validate test;
 set sashelp.heart;
 call streaminit(123456789);
 x=rand('table',0.6,0.3,0.1);
 if x=1 then output train;
  else if x=2 then output validate;
   else output test;
drop x;
run;



Greeshma
Fluorite | Level 6
Thank you

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!

What is Bayesian Analysis?

Learn the difference between classical and Bayesian statistical approaches and see a few PROC examples to perform Bayesian analysis in this video.

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
  • 4 replies
  • 1554 views
  • 10 likes
  • 3 in conversation