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

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!

1 ACCEPTED SOLUTION

Accepted Solutions
PGStats
Opal | Level 21

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

View solution in original post

3 REPLIES 3
PGStats
Opal | Level 21

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;
PG
Jonate_H
Quartz | Level 8

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!

 

 

PGStats
Opal | Level 21

Right! The sort would also have to be by sex region;

PG

hackathon24-white-horiz.png

2025 SAS Hackathon: There is still time!

Good news: We've extended SAS Hackathon registration until Sept. 12, so you still have time to be part of our biggest event yet – our five-year anniversary!

Register Now

How to Concatenate Values

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.

SAS Training: Just a Click Away

 Ready to level-up your skills? Choose your own adventure.

Browse our catalog!

Discussion stats
  • 3 replies
  • 1230 views
  • 0 likes
  • 2 in conversation