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;
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.