The script begins by creating a 'sleep' dataset simulating recall scores for different durations ('hours'). It then executes PROC GLMPOWER to determine the necessary sample size in a general linear model (ANOVA) to achieve powers of 0.7, 0.8, and 0.9. Finally, it uses PROC POWER to calculate the sample size required for a two-sample means comparison test (t-test) with a mean difference of 3 and a standard deviation of 30.
Data Analysis
Type : INTERNAL_CREATION
Data is generated via a DATA step with DATALINES statements (values 30 and 33).
1 Code Block
DATA STEP Data
Explanation : Creation of the 'sleep' dataset containing an explanatory variable 'hours' (1 and 2) and a response variable 'recall' read from the datalines.
Copied!
data sleep;
do hours = 1 to 2;
input recall;
output;
end;
datalines;
30
33
;
run;
1
DATA sleep;
2
DO hours = 1 to 2;
3
INPUT recall;
4
OUTPUT;
5
END;
6
DATALINES;
7
30
8
33
9
;
10
RUN;
2 Code Block
PROC GLMPOWER
Explanation : Power analysis for a general linear model (here, a one-way ANOVA with factor 'hours'). The script requests the calculation of the total sample size (ntotal = .) for target powers of 0.7, 0.8, and 0.9, with an assumed standard deviation of 30. A plot of power versus sample size is generated.
Copied!
proc glmpower data=sleep;
class hours;
model recall = hours;
power
stddev = 30
ntotal = .
power = 0.7 0.8 0.9;
plot x=power min=0.7 max=0.95;
run;
1
PROC GLMPOWERDATA=sleep;
2
class hours;
3
model recall = hours;
4
power
5
stddev = 30
6
ntotal = .
7
power = 0.70.80.9;
8
plot x=power min=0.7 max=0.95;
9
RUN;
3 Code Block
PROC POWER
Explanation : Power calculation for a two-sample means comparison test (t-test). Parameters: expected mean difference of 3, alpha of 0.05, standard deviation of 30. The code requests the required sample size for the specified power levels.
This material is provided "as is" by We Are Cas. There are no warranties, expressed or implied, as to merchantability or fitness for a particular purpose regarding the materials or code contained herein. We Are Cas is not responsible for errors in this material as it now exists or will exist, nor does We Are Cas provide technical support for it.
SAS and all other SAS Institute Inc. product or service names are registered trademarks or trademarks of SAS Institute Inc. in the USA and other countries. ® indicates USA registration. WeAreCAS is an independent community site and is not affiliated with SAS Institute Inc.
This site uses technical and analytical cookies to improve your experience.
Read more.