Hi all,
I want to understand how can I split a dataset into multiple datasets in different percentages.
Say I have a dataset Have and I want to split it into first 20% and rest equally into 3 parts.
Thanks in advance
I am sure that this question was asked many times before and almost always somebody answered: "why? Splitting data is a good idea in very, very few cases, only."
Some hints:
I agree with @andreas_lds, hardly ever a good idea.
However if you want to do it anyways, here is a nice example of how
First off, its generally better to not do so, assigning groups within the one dataset creates easier programming down the line.
If you wish to continue then surveyselect should be able to do it:
Which was mentioned in:
I feel like joining the party!
Don't split your data sets!
data x1 x2 x3 x4;
set sashelp.air;
call streaminit(123456789);
_id_=rand('table',0.2,0.8/3,0.8/3);
if _id_=1 then output x1;
else if _id_=2 then output x2;
else if _id_=3 then output x3;
else if _id_=4 then output x4;
run;
Are you ready for the spotlight? We're accepting content ideas for SAS Innovate 2025 to be held May 6-9 in Orlando, FL. The call is open until September 25. Read more here about why you should contribute and what is in it for you!
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.