I try to bootstrap using proc surveyselect or the following code
data bootstraps;
do replicate = 1 to 10;
do simorder = 1 to nobs;
p = ceil(nobs * ranuni(394747373));
set sample nobs=nobs point=p;
output;
end;
end;
stop;
run;
I want the bootstrap run by each id-month combination, rather than apply to the whole dataset. One way is to separate the dataset into small ones (e.g., for id=11, I have sub-dataset for month 1 and 2; and for id=22, also have subdatasets for month 1 and 2), then apply above code to each subdataset, finally merge. It works fine if I have only 2 firms.
Any options I can refer to, to bootstrap by firm and month? strata option looks like select different observations from different groups.
Thanks!
Look at this example:
proc sort data=sashelp.class out=orderedClass; by sex; run;
proc surveyselect data=orderedClass method=urs samprate=100 rep=10
out=bootstraps outhits seed=9636365;
strata sex;
run;
Look at this example:
proc sort data=sashelp.class out=orderedClass; by sex; run;
proc surveyselect data=orderedClass method=urs samprate=100 rep=10
out=bootstraps outhits seed=9636365;
strata sex;
run;
Thank you PG!
So the key point here is to set samprate=100, and if I want to sample by two variables, I just add another variable to the strata statement?
e.g, if there is another variable named region, then the statement:
strata sex region;
will sample by each combination of sex-region, and the samprate=100 will make sure that the bootstrap works within each combination of sex-region.
Correct me if I am wrong. thanks!
Right! The sort would also have to be by sex region;
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.
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.