Turn on suggestions

Auto-suggest helps you quickly narrow down your search results by suggesting possible matches as you type.

Showing results for

- Home
- /
- Programming
- /
- SAS Studio
- /
- Re: How do I Bootstrap a Custom-Made Statistic??

Options

- RSS Feed
- Mark Topic as New
- Mark Topic as Read
- Float this Topic for Current User
- Bookmark
- Subscribe
- Mute
- Printer Friendly Page

🔒 This topic is **solved** and **locked**.
Need further help from the community? Please
sign in and ask a **new** question.

- Mark as New
- Bookmark
- Subscribe
- Mute
- RSS Feed
- Permalink
- Report Inappropriate Content

Posted 02-23-2019 10:19 AM
(986 views)

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

- Mark as New
- Bookmark
- Subscribe
- Mute
- RSS Feed
- Permalink
- Report Inappropriate Content

Hi @MeasuringHealth and welcome to the SAS Support Communities!

- Create your bootstrap samples (
*not*using a macro, see David L. Cassell's paper BootstrapMania!: Re-Sampling the SAS® Way). - Compute the means and standard deviations using PROC SUMMARY (or PROC MEANS) with BY-group processing.
- Perform the SRM calculation in a DATA step based on the output dataset from step 2.
- 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

- Mark as New
- Bookmark
- Subscribe
- Mute
- RSS Feed
- Permalink
- Report Inappropriate Content

Hi,

Try this

data want;

if _n_=1 then set SRM;

set sample;

run;

- Mark as New
- Bookmark
- Subscribe
- Mute
- RSS Feed
- Permalink
- Report Inappropriate Content

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

- Mark as New
- Bookmark
- Subscribe
- Mute
- RSS Feed
- Permalink
- Report Inappropriate Content

Hi @MeasuringHealth and welcome to the SAS Support Communities!

- Create your bootstrap samples (
*not*using a macro, see David L. Cassell's paper BootstrapMania!: Re-Sampling the SAS® Way). - Compute the means and standard deviations using PROC SUMMARY (or PROC MEANS) with BY-group processing.
- Perform the SRM calculation in a DATA step based on the output dataset from step 2.
- 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.

- Mark as New
- Bookmark
- Subscribe
- Mute
- RSS Feed
- Permalink
- Report Inappropriate Content

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

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

SAS Enterprise Guide vs. SAS Studio

What’s the difference between SAS Enterprise Guide and SAS Studio? How are they similar? Just ask SAS’ Danny Modlin.

Find more tutorials on the SAS Users YouTube channel.