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

sas-innovate-2024.png

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.

 

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.

Click image to register for webinarClick image to register for webinar

Classroom Training Available!

Select SAS Training centers are offering in-person courses. View upcoming courses for:

View all other training opportunities.

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