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
Hi @MeasuringHealth and welcome to the SAS Support Communities!
Alternatively, a single PROC SQL step (with a GROUP BY clause) could replace steps 2 and 3.
Hi,
Try this
data want;
if _n_=1 then set SRM;
set sample;
run;
Hi @MeasuringHealth and welcome to the SAS Support Communities!
Alternatively, a single PROC SQL step (with a GROUP BY clause) could replace steps 2 and 3.
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
Save $250 on SAS Innovate and get a free advance copy of the new SAS For Dummies book! Use the code "SASforDummies" to register. Don't miss out, May 6-9, in Orlando, Florida.
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.
Ready to level-up your skills? Choose your own adventure.