Fluorite | Level 6

## How do I Bootstrap a Custom-Made Statistic??

Hi all, (I am using SAS Studio Release: 3.6 (Enterprise Edition), Engine 9)

I have computed the simple Standardized Response Mean (SRM) for my sample: mean/std=SRM. Now, I need to bootstrap this SRM to get the 95% confidence intervals. Unfortunately, the SRM is a function of the mean and standard deviation, so I am not able to simply use PROC MEANS with a BY statement. Or can I? What is the best way for me to do this??? I have little experience with macro writing...but am willing to learn if there is a simple macro to write.

Here is my code (again, my goal is to bootstrap the SRM variable, which is now in my output as a single observation):

``````/* ----------------------------------------------------------- */
/*     Bootstrapping the Standardized Response Mean (SRM)      */
/* ----------------------------------------------------------- */
PROC MEANS DATA=Sample noprint;
VAR ChangeScore;
OUTPUT out=preSRM mean(ChangeScore)=mean std(ChangeScore)=std;
RUN;
DATA SRM;
SET preSRM;
SRM=DIVIDE(mean,std);
RUN;

*NOW I NEED TO BOOTSTRAP THE SRM VARIABLE...;``````

Help!!!!

Thank you,

MeasuringHealth

1 ACCEPTED SOLUTION

Accepted Solutions

## Re: How do I Bootstrap a Custom-Made Statistic??

Hi @MeasuringHealth and welcome to the SAS Support Communities!

1. Create your bootstrap samples (not using a macro, see David L. Cassell's paper BootstrapMania!: Re-Sampling the SAS® Way).
2. Compute the means and standard deviations using PROC SUMMARY (or PROC MEANS) with BY-group processing.
3. Perform the SRM calculation in a DATA step based on the output dataset from step 2.
4. Using PROC UNIVARIATE, determine the 2.5th and 97.5th percentile of the SRM values in the dataset resulting from step 3 in order to obtain the bootstrap 95% CI.

Alternatively, a single PROC SQL step (with a GROUP BY clause) could replace steps 2 and 3.

4 REPLIES 4
Ammonite | Level 13

## Re: How do I Bootstrap a Custom-Made Statistic??

Hi,

Try this

data want;
if _n_=1 then set SRM;
set sample;
run;

Fluorite | Level 6

## Re: How do I Bootstrap a Custom-Made Statistic??

Okay, I'll try...any hint on the code I should write after that?

## Re: How do I Bootstrap a Custom-Made Statistic??

Hi @MeasuringHealth and welcome to the SAS Support Communities!

1. Create your bootstrap samples (not using a macro, see David L. Cassell's paper BootstrapMania!: Re-Sampling the SAS® Way).
2. Compute the means and standard deviations using PROC SUMMARY (or PROC MEANS) with BY-group processing.
3. Perform the SRM calculation in a DATA step based on the output dataset from step 2.
4. Using PROC UNIVARIATE, determine the 2.5th and 97.5th percentile of the SRM values in the dataset resulting from step 3 in order to obtain the bootstrap 95% CI.

Alternatively, a single PROC SQL step (with a GROUP BY clause) could replace steps 2 and 3.

Fluorite | Level 6

## Re: How do I Bootstrap a Custom-Made Statistic??

Thank you very much, @FreelanceReinh!!

I should have called upon you sooner. For anyone that may benefit from seeing it, here is my successful code (built by using @FreelanceReinh's suggestion):

``````/* ----------------------------------------------------------- */
/*     Bootstrapping the Standardized Response Mean (SRM)      */
/* ----------------------------------------------------------- */

/*--- Bootstrapping the samples ---*/
SASFILE SEVERITY load; /* 1 */
PROC SURVEYSELECT DATA=SEVERITY out=outboot /* 2 */
SEED=1 /* 3 */
METHOD=urs /* 4 */
SAMPRATE=1 /* 5 */
OUTHITS /* 6 */
rep=1000; /* 7 */
RUN;
SASFILE SEVERITY close; /* 8 */

/*--- Compute means & standard deviations from bootstrap samples ---*/
PROC MEANS DATA=outboot noprint;
BY Replicate;
VAR GASIchange;
OUTPUT out=preSRM mean(GASIchange)=mean std(GASIchange)=std;
RUN;

/*--- Perform SRM calculation on bootstrapped statistics ---*/
DATA bootSRM;
SET preSRM;
bootSRM=DIVIDE(mean,std);
RUN;

/*--- Compute 95% bootstrap confidence interval ---*/
PROC UNIVARIATE DATA=bootSRM;
VAR bootSRM;
HISTOGRAM bootSRM;
OUTPUT out=Pctl pctlpre=CI95_
pctlpts=2.5 97.5
pctlname=Lower Upper;
RUN;``````

Best,

MeasuringHealth

Discussion stats
• 4 replies
• 987 views
• 3 likes
• 3 in conversation