BookmarkSubscribeRSS Feed
data_null__
Jade | Level 19

Yes, but if you want examples you will need to be more specific. 

8 REPLIES 8
Idunnu
Calcite | Level 5

Suppose i want to subtract the mean of sbp in StdTyp 1 Period 1 Trtgrp 1 (highlighted) from the mean of StdTyp 1 Period 1 Trtgrp 2 (highlighted) to give a variable called X, what code do i use? I have pasted the output below. thanks. Tried different things but didnt work.

The MEANS Procedure

StdTyp Period Trtgrp N obs variable N mean Std Dev Minimum Maximum

                                                     

           

11154
sbp
dbp
54
54
118.7777778
73.9444444
16.4439203
8.9493684
95.0000000
58.0000000
156.0000000
90.0000000
281
sbp
dbp
81
81
110.8765432
72.3086420
23.4762554
15.2271484
0
0
138.0000000
90.0000000
2181
sbp
dbp
78
78
117.2435897
77.2948718
13.7152734
7.8807821
92.0000000
60.0000000
148.0000000
94.0000000
254
sbp
dbp
54
54
118.9074074
73.4259259
18.7035145
9.8853844
94.0000000
56.0000000
168.0000000
96.0000000
21118
sbp
dbp
18
18
107.6666667
68.1111111
11.9410316
5.6868154
92.0000000
59.0000000
130.0000000
77.0000000
354
sbp
dbp
54
54
121.4074074
75.5555556
14.7884689
9.8472612
86.0000000
60.0000000
148.0000000
102.0000000
2154
sbp
dbp
54
54
121.7222222
77.3148148
12.7374306
8.0863829
98.0000000
64.0000000
149.0000000
94.0000000
318
sbp
dbp
18
18
104.1666667
67.8333333
4.6684170
4.5406659
98.0000000
62.0000000
114.0000000

78.0000000

Idunnu
Calcite | Level 5

@data_null_;

data_null__
Jade | Level 19

Based on the data set name and variables names I think perhaps you should ask about this as a statistical analysis question not just as a data summary.  Perhaps could look at your data give some advice.

However I will show you how you can use PROC ANOVA to compute the means differences as per your example.  Using PROC ANOVA allows you do get the differences directly without having to do much in the way of data manipulation.

data crossoverdesign;   
  
infile datalines delimiter=','
  
input Id StdTyp Period Trtgrp @;
   do d=1 to 3;
     
do r=1 to 3;
        
input sbp dbp @;
         if sbp eq 999 then sbp=.;
        
if dbp eq 999 then dbp=.;
        
output;
        
end;
     
end;  
  
datalines
3,1,1,1,134,82,122,80,118,80,112,76,130,84,120,82,114,76,104,74,114,76 
3,1,2,2,113,61,116,72,115,67,122,70,136,76,128,72,122,72,126,72,123,71 
4,2,1,3,142,90,134,88,134,84,122,76,116,76,114,74,122,84,124,78,116,80 
4,2,2,1,128,86,133,81,135,81,129,83,116,74,130,80,138,84,140,80,134,74 
5,1,1,1,134,78,138,84,126,80,122,74,120,76,122,78,140,82,134,84,136,84 
5,1,2,2,126,76,122,74,116,76,134,82,126,88,130,84,132,78,128,82,126,78 
8,2,1,3,112,72,114,70,116,70,120,78,122,76,116,76,118,72,113,75,113,73 
8,2,2,1,116,72,106,76,110,72,125,75,131,73,126,78,110,68,109,67,105,71 
9,1,1,2,116,70,112,72,108,70,124,70,110,70,112,74,114,78,120,72,116,76 
9,1,2,1,102,60,104,64,104,66,110,74,107,77,112,74,104,64,113,75,102,70 
10,1,1,2,109,73,107,77,104,80,110,74,114,74,110,74,119,79,119,75,112,80   
10,1,2,1,118,78,117,83,118,82,108,72,106,70,98,70,117,81,110,78,110,80 
14,1,1,1,116,64,97,61,100,60,118,73,125,77,119,69,106,70,107,73,110,70 
14,1,2,2,114,70,110,72,112,76,100,66,113,73,100,68,116,74,112,74,112,72   
22,3,1,2,122,78,114,76,114,72,110,76,102,68,105,73,116,68,106,66,106,72   
22,3,2,3,102,64,112,74,120,80,112,74,100,78,116,72,95,67,100,70,100,70 
25,3,1,2,102,60,94,62,94,66,96,62,103,65,103,61,110,70,121,71,125,77   
25,3,2,3,98,60,101,65,96,64,99,59,101,65,98,60,102,62,96,68,104,62  
27,1,1,2,126,80,130,80,120,78,122,80,128,74,122,82,128,78,121,77,123,77   
27,1,2,1,116,76,120,72,120,74,134,84,136,88,128,84,136,86,136,82,132,80   
29,1,1,1,111,67,110,72,106,66,95,65,105,65,104,62,96,58,98,64,100,60   
29,1,2,2,109,71,112,72,110,72,94,62,96,62,98,60,108,70,102,70,100,66   
30,3,1,3,110,62,111,61,99,55,110,62,110,62,112,62,104,64,104,64,108,60 
30,3,2,2,116,68,114,64,114,64,102,60,100,56,106,56,116,66,108,62,108,64   
31,2,1,3,134,82,136,72,128,72,130,80,131,73,129,75,134,82,132,78,132,74   
31,2,2,1,122,74,128,78,124,80,126,78,126,72,128,78,126,82,132,80,136,80   
32,2,1,1,114,66,106,68,106,66,122,72,130,74,124,76,118,62,121,77,116,72   
32,2,2,3,104,62,103,67,102,66,109,69,106,66,104,66,114,70,108,70,112,72   
33,1,1,1,156,86,154,76,144,86,148,88,140,88,142,86,144,90,132,86,140,86   
33,1,2,2,168,94,146,96,154,92,157,89,158,90,158,90,133,83,142,84,146,88   
34,1,1,2,122,76,116,74,116,76,127,77,114,72,114,70,126,72,116,66,118,72   
34,1,2,1,126,80,126,80,120,82,113,71,116,74,108,74,110,72,109,71,110,78   
35,1,1,2,98,64,98,70,98,68,108,66,106,76,104,70,102,64,96,70,100,66 
35,1,2,1,999,999,999,999,999,999,106,74,98,76,96,76,98,66,97,71,92,62  
36,2,1,1,96,60,104,66,94,64,100,70,100,74,106,74,96,64,92,62,93,59  
36,2,2,3,100,72,104,74,108,78,103,63,104,62,98,64,98,64,98,64,100,72   
37,1,1,2,118,74,114,70,112,68,110,72,110,70,113,69,116,76,122,76,116,74   
37,1,2,1,126,84,127,83,120,82,126,78,125,77,118,80,106,64,104,68,110,68   
39,3,1,2,128,86,124,84,126,84,132,80,130,86,134,82,114,74,112,74,112,82   
39,3,2,3,123,79,120,82,124,84,106,68,102,72,102,72,108,76,112,74,106,76   
40,2,1,3,96,64,106,70,99,67,110,60,96,62,86,60,98,62,92,60,91,63 
40,2,2,1,121,77,118,76,116,82,104,68,107,69,108,76,99,75,98,64,98,70   
42,3,1,2,138,80,136,74,133,79,154,88,144,80,149,81,134,84,127,77,126,74   
42,3,2,3,126,76,125,75,121,73,130,76,118,80,118,68,132,74,118,70,126,74   
48,1,1,2,108,72,108,72,108,76,108,70,120,76,118,78,0,0,0,0,0,0   
48,1,2,1,106,74,108,70,108,70,111,71,112,78,116,78,104,70,100,68,101,65   
49,3,1,3,90,62,94,64,86,60,90,60,92,60,86,56,86,58,87,59,90,60   
49,3,2,2,88,64,88,60,92,66,86,60,94,60,92,64,88,56,92,62,92,62   
50,1,1,1,114,68,106,66,106,70,100,66,100,70,105,63,112,64,98,64,110,64 
50,1,2,2,98,62,96,58,96,56,106,66,98,66,99,63,105,67,102,58,100,62  
52,2,1,3,129,67,120,68,130,72,121,67,118,66,114,68,114,70,111,67,114,68   
52,2,2,1,118,70,120,70,106,72,112,68,116,68,118,70,108,66,108,68,108,68   
53,1,1,2,112,84,112,82,114,84,110,76,110,74,112,78,112,88,114,84,114,84   
53,1,2,1,120,82,124,86,112,82,140,88,131,91,128,92,112,78,114,88,121,87   
57,1,1,2,124,82,132,84,132,90,118,70,120,80,110,72,130,80,138,80,131,79   
57,1,2,1,136,88,136,86,142,90,148,88,142,90,140,94,142,72,138,84,148,84   
58,3,1,2,94,74,98,66,86,68,102,70,98,66,90,64,86,64,96,66,94,66  
58,3,2,3,102,66,100,74,96,68,96,70,103,73,99,73,102,74,100,68,94,68 
61,2,1,3,144,92,139,83,142,90,134,92,138,88,134,90,136,90,148,102,142,92  
61,2,2,1,146,94,144,92,149,93,138,92,126,90,128,92,134,90,132,90,124,88   
62,3,1,3,104,64,100,66,96,64,100,66,100,70,103,67,104,70,102,66,102,68 
62,3,2,2,106,70,108,68,98,74,106,70,102,68,102,70,103,65,100,64,96,64  
;;;;
   run
proc sort data=crossoverdesign;
   by stdtyp period trtgrp;
   run;
proc anova data=crossoverdesign;
   by stdtyp period;
   class trtgrp;
   model sbp dbp = trtgrp;
   means trtgrp / cldiff dunnett;
  
ods select none;
  
ods output CLDiffs=CLDiffs(drop=method uppercl lowercl significance);
   run;
ods select all;
proc print data=CLDiffs;
   run;
SteveDenham
Jade | Level 19

Follow the advice of data_null_;  This will give you the differences in the raw means you are looking for.

Then start thinking about things like cross-over designs, repeated measures on subjects, unbalancedness, and the fact that sbp (systolic blood pressure?) and dbp (diastolic blood pressure) are surely correlated within subject as well.  A full description of the experimental design would lead to a more comprehensive analysis.

My biggest problem with unbalanced designs is that the difference between raw means is a biased estimator of effects.

Steve Denham

Idunnu
Calcite | Level 5

TThanks! @data_null_; .... I appreciate your responses!!!

Idunnu
Calcite | Level 5

yea, its actually a crossover design analysis

SteveDenham
Jade | Level 19

Then the raw means are relatively meaningless.  Google is your friend--there are multiple examples out there of the analysis of cross-over designs using PROC GLM, PROC MIXED and PROC GLIMMIX.  The lsmeans generated from these analyses accommodate the multiple effects, and the imbalance seen.  I would really suggest going that way with this data.

Steve Denham

Idunnu
Calcite | Level 5

YEa, I ended up using the proc mixed method but I'll need the raw means just to get a description of the two variables.. Thank you!!

sas-innovate-2024.png

Join us for SAS Innovate April 16-19 at the Aria in Las Vegas. Bring the team and save big with our group pricing for a limited time only.

Pre-conference courses and tutorials are filling up fast and are always a sellout. Register today to reserve your seat.

 

Register now!

What is Bayesian Analysis?

Learn the difference between classical and Bayesian statistical approaches and see a few PROC examples to perform Bayesian analysis in this video.

Find more tutorials on the SAS Users YouTube channel.

Click image to register for webinarClick image to register for webinar

Classroom Training Available!

Select SAS Training centers are offering in-person courses. View upcoming courses for:

View all other training opportunities.

Discussion stats
  • 8 replies
  • 1215 views
  • 0 likes
  • 3 in conversation