I have this data set A with N=100. I want to create a data set B with N=75 through simple random sampling without replacement and the remaining 25 should be data set C.
Help!
Beginning with SAS 9.4 Proc Surveyselect allows you to directly create both data sets.
http://support.sas.com/kb/36/383.html
In case you haven't a SAS license which gives you access to Proc Surveyselect: There is also a data step approach possible. Just amend the code in Method 3 under this link http://support.sas.com/kb/24/722.html to write non selected rows to another table.
proc surveyselect data=have out=sampled sampsize=75 outall; run;
will create a data set sampled with all of the records from the have set and a variable Selected to indicate whether it was selected for the 75 or not. If you want a percentage of records then use SAMPRATE instead of SAMPSIZE.
If you really need to split the data then a separate data step
data samp75 samp25; set sampled; if selected then output samp75; else output samp25; run;
Beginning with SAS 9.4 Proc Surveyselect allows you to directly create both data sets.
http://support.sas.com/kb/36/383.html
In case you haven't a SAS license which gives you access to Proc Surveyselect: There is also a data step approach possible. Just amend the code in Method 3 under this link http://support.sas.com/kb/24/722.html to write non selected rows to another table.
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.
Need to connect to databases in SAS Viya? SAS’ David Ghan shows you two methods – via SAS/ACCESS LIBNAME and SAS Data Connector SASLIBS – in this video.
Find more tutorials on the SAS Users YouTube channel.