|
|
|
||||
|
|
|||||
Figure 2.1 on page 18.
title1 'Figure 2.1a 'Person-level' data set'; proc print data='c:\alda\tolerance'; run; Figure 2.1a Person-level data set Obs ID TOL11 TOL12 TOL13 TOL14 TOL15 MALE EXPOSURE 1 9 2.23 1.79 1.90 2.12 2.66 0 1.54 2 45 1.12 1.45 1.45 1.45 1.99 1 1.16 3 268 1.45 1.34 1.99 1.79 1.34 1 0.90 4 314 1.22 1.22 1.55 1.12 1.12 0 0.81 5 442 1.45 1.99 1.45 1.67 1.90 0 1.13 6 514 1.34 1.67 2.23 2.12 2.44 1 0.90 7 569 1.79 1.90 1.90 1.99 1.99 0 1.99 8 624 1.12 1.12 1.22 1.12 1.22 1 0.98 9 723 1.22 1.34 1.12 1.00 1.12 0 0.81 10 918 1.00 1.00 1.22 1.99 1.22 0 1.21 11 949 1.99 1.55 1.12 1.45 1.55 1 0.93 12 978 1.22 1.34 2.12 3.46 3.32 1 1.59 13 1105 1.34 1.90 1.99 1.90 2.12 1 1.38 14 1542 1.22 1.22 1.99 1.79 2.12 0 1.44 15 1552 1.00 1.12 2.23 1.55 1.55 0 1.04 16 1653 1.11 1.11 1.34 1.55 2.12 0 1.25
Creating a person-period data set from a balanced person-level data set
data tolerance_pp;
set 'c:\alda\tolerance';
array Atol [11:15] tol11-tol15;
do age=11 to 15;
tol = Atol[age];
time = age - 11;
output;
end;
keep id age time tol male exposure;
run;
title1 'Figure 2.1b 'Person-Period' data set';
proc print data=tolerance_pp;
var id age tol male exposure;
run;
Figure 2.1b Person-Period data set
Obs ID age tol MALE EXPOSURE 1 9 11 2.23 0 1.54 2 9 12 1.79 0 1.54 3 9 13 1.90 0 1.54 4 9 14 2.12 0 1.54 5 9 15 2.66 0 1.54 6 45 11 1.12 1 1.16 7 45 12 1.45 1 1.16 ........................................... 72 1552 12 1.12 0 1.04 73 1552 13 2.23 0 1.04 74 1552 14 1.55 0 1.04 75 1552 15 1.55 0 1.04 76 1653 11 1.11 0 1.25 77 1653 12 1.11 0 1.25 78 1653 13 1.34 0 1.25 79 1653 14 1.55 0 1.25 80 1653 15 2.12 0 1.25
Table 2.1, page 20
title1 'Table 2.1: Estimated bivariate correlations among tolerance scores'; options nocenter nodate nolabel; proc corr data='c:\alda\tolerance' nosimple noprob; var tol11-tol15; run; Table 2.1: Estimated bivariate correlations among tolerance scores
The CORR Procedure
5 Variables: TOL11 TOL12 TOL13 TOL14 TOL15
Pearson Correlation Coefficients, N = 16
TOL11 TOL12 TOL13 TOL14 TOL15
TOL11 1.00000 0.65729 0.06195 0.14076 0.26354
TOL12 0.65729 1.00000 0.24755 0.20562 0.39228
TOL13 0.06195 0.24755 1.00000 0.58717 0.56921
TOL14 0.14076 0.20562 0.58717 1.00000 0.82546
TOL15 0.26354 0.39228 0.56921 0.82546 1.00000
Figure 2.2 , page 25. The first proc greplay deletes all the current graphs in the work directory so the naming for the next proc greplay will work properly. We also disabled the vertical variable name appeared as specified in the option of label. Instead we used title option to make use the facility of moving it to exactly where we want it to be. To create Figure 2.2, we actually used proc greplay three times. The first time, we create four graphs with four plots on each panel. Then we combine the two panels at a time to get two panels with eight plots on each panel. In last step, we put together the two panels to get one single graph.
proc greplay igout = work.gseg nofs;
delete _all_;
run;
goptions reset=all noborder ftext=titalic
rotate = portrait htext=4 hby=0 vsize=7.9 hsize=7;
symbol color=black i=none value=dot height=2 ;
axis1 label=('AGE' ) minor=none ;
axis2 label = none order=(0 to 4 by 1) minor=none;
title justify = left height=3 move=(10, -1) 'TOL';
proc gplot data=tolerance_pp uniform;
by id;
note justify=right 'ID #byval(ID)';
plot tol*age / nolegend haxis=axis1 vaxis=axis2 noframe;
run;
quit;
proc greplay igout=work.gseg tc=sashelp.templt
template=h4 nofs;
treplay 1:1 2:2 3:3 4:4;
treplay 1:5 2:6 3:7 4:8;
treplay 1:9 2:10 3:11 4:12;
treplay 1:13 2:14 3:15 4:16;
run;
quit;
proc greplay igout=work.gseg tc=sashelp.templt
template=v2 nofs nobyline;
treplay 1:template 2:templat1;
treplay 1: templat2 2: templat3;
run;
quit;
proc greplay igout=work.gseg tc=sashelp.templt
template=v2 nofs nobyline;
treplay 1:templat4 2:templat5;
run;
quit;
Figure 2.3, page 27. This is very similar to Figure 2.2. For details, see the example above.
proc greplay igout = work.gseg nofs;
delete _all_;
run;
goptions reset=all noborder ftext=titalic nocell
rotate = portrait htext=4 hby=0 vsize=7.9 hsize=7;
symbol color=black i=none value=dot height=2 ;
axis1 label=('AGE' ) minor=none ;
axis2 label = none order=(0 to 4 by 1) minor=none;
title justify = left height=3 move=(10, -4) 'TOL';
proc gplot data=tolerance_pp uniform ;
note justify=center 'ID #byval(ID)';
symbol color=black interpol=spline value=dot height=2 ;
by id;
plot tol*age / nolegend haxis=axis1 vaxis=axis2 noframe;
run;
proc greplay igout=work.gseg tc=sashelp.templt
template=h4 nofs;
treplay 1:1 2:2 3:3 4:4;
treplay 1:5 2:6 3:7 4:8;
treplay 1:9 2:10 3:11 4:12;
treplay 1:13 2:14 3:15 4:16;
run;
quit;
proc greplay igout=work.gseg tc=sashelp.templt
template=v2 nofs nobyline;
treplay 1:template 2:templat1;
treplay 1: templat2 2: templat3;
run;
quit;
proc greplay igout=work.gseg tc=sashelp.templt
template=v2 nofs nobyline;
treplay 1:templat4 2:templat5;
run;
quit;
proc greplay igout=work.fig23 gout= work.fig23 nofs;
tc sashelp.templt ;
template eight;
treplay 1:1 2:2 3:3 4:4 5:5 6:6 7:7 8:8;
treplay 1:9 2:10 3:11 4:12 5:13 6:14 7:15 8:16;
run;
quit;
proc greplay igout=work.fig23 tc=sashelp.templt
template=v2 nofs nobyline;
treplay 1:template 2:templat1;
run;
Table 2.2, page 30.
Title1 'Table 2.2: Results of fitting separate within-person exploratory OLS regression models'; proc reg data=tolerance_pp outseb outest=estbyid rsquare noprint; model tol=time; by id; run; data parest_all; set estbyid; by id; retain in_status se_in r_change se_rchange resvar r2; if first.id then do; in_status = intercept; r_change = time; r2 = _rsq_; end; if last.id then do; se_in = intercept; se_rchange = time; resvar = _rmse_**2; output; end; keep id in_status se_in r_change se_rchange resvar r2; run; data exploratory; merge parest_all tolerance; by id; keep id in_status se_in r_change se_rchange resvar r2 male exposure; run;
proc print data=exploratory noobs; format _numeric_ 4.2; format id 4.0; run;
Table 2.2: Results of fitting separate within-person exploratory OLS regression models
ID in_status se_in r_change se_rchange resvar r2 MALE EXPOSURE
9 1.90 0.25 0.12 0.10 0.11 0.31 0.00 1.54 45 1.14 0.13 0.17 0.05 0.03 0.77 1.00 1.16 268 1.54 0.26 0.02 0.11 0.11 0.02 1.00 0.90 314 1.31 0.15 -.03 0.06 0.04 0.07 0.00 0.81 442 1.58 0.21 0.06 0.08 0.07 0.13 0.00 1.13 514 1.43 0.14 0.26 0.06 0.03 0.88 1.00 0.90 569 1.82 0.03 0.05 0.01 0.00 0.88 0.00 1.99 624 1.12 0.04 0.02 0.02 0.00 0.33 1.00 0.98 723 1.27 0.08 -.05 0.03 0.01 0.45 0.00 0.81 918 1.00 0.30 0.14 0.12 0.15 0.31 0.00 1.21 949 1.73 0.24 -.10 0.10 0.10 0.25 1.00 0.93 978 1.03 0.32 0.63 0.13 0.17 0.89 1.00 1.59 1105 1.54 0.15 0.16 0.06 0.04 0.68 1.00 1.38 1542 1.19 0.18 0.24 0.07 0.05 0.78 0.00 1.44 1552 1.18 0.37 0.15 0.15 0.23 0.25 0.00 1.04 1653 0.95 0.14 0.25 0.06 0.03 0.86 0.00 1.25
Figure 2.4, page 31
title1 'Figure 2.4. Stem and Leaf Plots'; title2 'for Initial Status, Rate of Change, Resid Variance, and Rsquared'; proc univariate data=exploratory plot ; var in_status r_change resvar r2; run;
Figure 2.4. Stem and Leaf Plots for Initial Status, Rate of Change, Resid Variance, and Rsquared
<output edited to show just stem and leaf plots>
Variable: in_status
Stem Leaf # Boxplot
18 20 2 |
16 3 1 |
14 3448 4 +-----+
12 71 2 *--+--*
10 032489 6 +-----+
8 5 1 |
----+----+----+----+
Multiply Stem.Leaf by 10**-1
Variable: r_change
Stem Leaf # Boxplot
6 3 1 0
5
4
3
2 456 3 +-----+
1 24567 5 *--+--*
0 2256 4 +-----+
-0 53 2 |
-1 0 1 |
----+----+----+----+
Multiply Stem.Leaf by 10**-1
Variable: resvar
Stem Leaf # Boxplot
2 3 1 0
1 57 2 |
1 011 3 +-----+
0 57 2 *--+--*
0 00133344 8 +-----+
----+----+----+----+
Multiply Stem.Leaf by 10**-1
Variable: r2
Stem Leaf # Boxplot
8 6889 4 +-----+
7 78 2 | |
6 8 1 | |
5 | |
4 5 1 | + |
3 113 3 *-----*
2 55 2 +-----+
1 3 1 |
0 27 2 |
----+----+----+----+
Multiply Stem.Leaf by 10**-1
Figure 2.5, page 32.
proc greplay igout = work.gseg nofs;
delete _all_;
run;
goptions reset=all noborder ftext=titalic nocell
rotate = portrait htext=4 hby=0 vsize=7.9 hsize=7;
axis1 label=('AGE' ) minor=none ;
axis2 label = none order=(0 to 4 by 1) minor=none;
symbol color=black interpol=reg value=dot height=2 ;
title justify = left height=3 move=(10, -4) 'TOL';
proc gplot data=tolerance_pp uniform;
by id;
note justify=center 'ID #byval(ID)';
plot tol*age/nolegend haxis=axis1 vaxis=axis2 noframe;
run;
proc greplay igout=work.gseg tc=sashelp.templt
template=h4 nofs;
treplay 1:1 2:2 3:3 4:4;
treplay 1:5 2:6 3:7 4:8;
treplay 1:9 2:10 3:11 4:12;
treplay 1:13 2:14 3:15 4:16;
run;
quit;
proc greplay igout=work.gseg tc=sashelp.templt
template=v2 nofs nobyline;
treplay 1:template 2:templat1;
treplay 1: templat2 2: templat3;
run;
quit;
proc greplay igout=work.gseg tc=sashelp.templt
template=v2 nofs nobyline;
treplay 1:templat4 2:templat5;
run;
quit;
Figure 2.6, page 34Create average values by age for Figure 2.6
proc means data=tolerance_pp noprint nway; class age; var tol; output out=one mean= ; run; data both; set one tolerance_pp; if id = . then ID = 9999; keep age tol id; run; proc sort data=both; by id; run;
Create fitted non-parametric smoothing to outcome over time for Figure 2.6
proc datasets memtype=catalog;
delete fig26;
run;
title ' ';
axis1 label=('AGE') order=(11 to 15 by 1) offset=(2 cm) minor=none ;
axis2 label=('TOL') order=(0 to 4 by 1) minor=none;
goptions nodisplay noborder cback=white ftext=titalic htext=3 hby=3 ;
proc gplot data=both gout=fig26;
symbol1 color=black interpol=spline value=none height=2 repeat=16;
symbol2 color=red interpol=spline value=none width=20 repeat=1;
plot tol*age=id/nolegend haxis=axis1 vaxis=axis2 noframe;
run;
Create fitted OLS regression lines to outcome over time for Figure 2.6.
proc gplot data=both gout=fig26; symbol color=black interpol=rl value=none height=2 repeat=16; symbol2 color=red interpol=rl value=none width=20 repeat=1; plot tol*age=id/nolegend haxis=axis1 vaxis=axis2 noframe; run;
Show graph for Figure 2.6 using template v2 from built in catalog sashelp.templt.
goptions reset=goptions; proc greplay igout=fig26 tc=sashelp.templt template=v2 nofs; treplay 1:1 2:2; run; quit;
Table 2.3, page 37
Title1 'Table 2.3: Descriptive statistics for the individual growth
parameters from separate OLS models';
proc corr data=exploratory;
var in_status r_change;
run;
Table 2.3: Descriptive statistics for the individual growth parameters from separate OLS models
The CORR Procedure
2 Variables: in_status r_change
Simple Statistics
Variable N Mean Std Dev Sum Minimum Maximum
in_status 16 1.35775 0.29778 21.72400 0.95400 1.90200 r_change 16 0.13081 0.17230 2.09300 -0.09800 0.63200
Pearson Correlation Coefficients, N = 16
in_status r_change
in_status 1.00000 -0.44811
r_change -0.44811 1.00000
Figure 2.7, page 38. It consists of four plots. We will do the first plots by gender and the next two by exposure. At the end, we use proc greplay to put the four plots together.
* The first part for variable male;
proc means data=tolerance_pp noprint nway;
class age male ;
var tol;
output out=gender mean= ;
run;
data tol_gender;
set tolerance_pp gender;
if id = . then ID = 9999;
keep age tol id male;
run;
proc sort data=tol_gender;
by male id;
run;
proc greplay igout=fig27 nofs;
delete _all_;
run;
quit;
goptions reset=all noborder ftext=titalic htext=3 hby=3 ;
axis1 label=('AGE') order=(11 to 15 by 1) offset=(2 cm) minor=none ;
axis2 label=('TOL') order=(0 to 4 by 1) minor=none;
symbol1 color=black interpol=rl value=none height=2 repeat=9;
symbol2 color=red interpol=rl value=none width=10 repeat=1;
proc gplot data=tol_gender gout=fig27;
where male = 0;
plot tol*age=id/nolegend haxis=axis1 vaxis=axis2 noframe;
title 'Males';
run;
quit;
symbol1 color=black interpol=rl value=none height=2 repeat=7;
symbol2 color=red interpol=rl value=none width=10 repeat=1;
proc gplot data=tol_gender gout=fig27;
where male = 1;
plot tol*age=id/nolegend haxis=axis1 vaxis=axis2 noframe;
title 'Females';
run;
quit;
*The second part for variable exposure; proc means data = tolerance_pp median; /*calculating median*/ var exposure; run; data tol_exp; set tolerance_pp; hiexp = (exposure >=1.145); run; proc means data= tol_exp noprint nway; class age hiexp; var tol; output out=loexp mean= ; run;
data tol_exp_all; set tol_exp loexp; if id = . then ID = 9999; keep age tol id hiexp; run;
proc sort data=tol_exp_all; by hiexp id; run;
symbol1 color=black interpol=rl value=none height=2 repeat=8; symbol2 color=red interpol=rl value=none width=10 repeat=1; proc gplot data=tol_exp_all gout=fig27; where hiexp = 0; plot tol*age=id/nolegend haxis=axis1 vaxis=axis2 noframe; title 'Low exposure'; run; quit; symbol1 color=black interpol=rl value=none height=2 repeat=8; symbol2 color=red interpol=rl value=none width=10 repeat=1; proc gplot data=tol_exp_all gout=fig27; where hiexp = 1; plot tol*age=id/nolegend haxis=axis1 vaxis=axis2 noframe; title 'High exposure'; run; quit;
Use proc greplay to show the four graphs all as one graph using built in template from sashelp.templt called l2r2 .
goptions reset=all noborder hby=3 hsize = 0 vsize=0 ; proc greplay igout=fig27 tc=sashelp.templt template=l2r2 nofs ; treplay 1:1 2:3 3:2 4:4; run; quit;
Figure 2.8, page 40
proc greplay igout = fig28 nofs; delete _all_;; run; options nolabel; proc corr data = exploratory nosimple noprob; var in_status r_change; with male exposure; run;
The CORR Procedure
2 With Variables: MALE EXPOSURE 2 Variables: in_status r_change
Pearson Correlation Coefficients, N = 16
in_status r_change
MALE 0.00863 0.19357
EXPOSURE 0.23244 0.44209
goptions reset=all noborder ftext=titalic htext=3 hby=3 ;
axis1 label=("MALE") order=(0 to 1) offset=(2 cm) minor=none ;
axis2 label=("EXPOSURE") order=(0 to 2 by 1) minor=none;
axis3 label=(a=90 "Fitted Initial Status") order=(.5 to 2.5 by .5) minor=none ;
axis4 label=(a=90 "Fitted Rate of Change") order=(-.2 to .8 by .2) minor=none ;
symbol1 color=black interpol=none value=dot height=2;
proc gplot data=exploratory gout=fig28;
title move=(80,10) h = 2 'r = 0.01';
plot in_status*male / nolegend haxis=axis1 vaxis=axis3 noframe;
proc gplot data=exploratory gout=fig28;
title move=(80,10) h = 2 'r = 0.23';
plot r_change*male / nolegend haxis=axis1 vaxis=axis4 noframe;
proc gplot data=exploratory gout=fig28;
title move=(80,10) h = 2 'r = 0.19';
plot in_status*exposure / nolegend haxis=axis2 vaxis=axis3 noframe;
proc gplot data=exploratory gout=fig28;
title move=(80,10) h = 2 'r = 0.44';
plot r_change*exposure / nolegend haxis=axis2 vaxis=axis4 noframe;
run;
quit;
Use proc greplay to show the four graphs all as one graph using built in template from sashelp.templt called l2r2 .
goptions reset=goptions ; proc greplay igout=fig28 tc=sashelp.templt template=l2r2 nofs ; treplay 1:1 2:2 3:3 4:4; run; quit;

UCLA Researchers are invited to our Statistical Consulting Services
We recommend others to our list of Other Resources for Statistical Computing Help
These pages are Copyrighted (c) by UCLA Academic Technology Services