Hello everyone,
I want to calculate adjusted mean by using proc mixe as in Table 12 (please see attached mock shells). I have attached my sas file and data file.
Thank you
Many of us will not download files (especially Microsoft Office files) as they can be a security threat.
Please provide your code by copying it as text and pasting it into the box that appears when you click on the "little running man" icon. Please provide a portion of your data following these instructions: https://blogs.sas.com/content/sastraining/2016/03/11/jedi-sas-tricks-data-to-data-step-macro/
Please explain what "adjusted mean" you are looking for. And please explain what problems you are having with your code.
When you provide spreadsheets as "data" we have to make decisions to turn it into a SAS data set.
My decisions are not likely to be yours. So I may not have variables of the same name or type as your SAS data set.
So besides the security risks or organization policies of not opening files from unknown sources I don't open spreadsheets as "data".
Instructions here: https://communities.sas.com/t5/SAS-Communities-Library/How-to-create-a-data-step-version-of-your-dat... will show how to turn an existing SAS data set into data step code that can be pasted into a forum code box using the </> or "running man" icon or attached as text to show exactly what you have and that we can test code against.
What you wanted might be obtained by using the LSMEANS statement in PROC MIXED --
lsmeans avisitn*trt01p;
The result from this LSMEANS statement would depend on your PROC MIXED model. The independent variables in your model statement would include avisitn trt01p avisitn*trt01p and other effects that you will have to decide what to include. You also need to specify a CLASS statement for your classification variables, and a RANDOM or a REPEATED statement to model the correlations in the repeated measures. You might find an example in the PROC MIXED documentation helpful --
https://go.documentation.sas.com/doc/en/pgmsascdc/v_012/statug/statug_mixed_examples02.htm
Jill
Hi everyone,
Thank you for your reply. My data is as below.
| USUBJID | AGegr1 | Trt01p | AVALC | NEREASN | trtN |
| LRN-12-6007 | <65 | Placebo | NE | Death Before Measurement | 2 |
| LRN-12-6007 | <65 | Total | NE | Death Before Measurement | 3 |
| LRN-12-6009 | <65 | CMP123 | PR |
| 1 |
| LRN-12-6009 | <65 | Total | PR |
| 3 |
| LRN-12-6151 | <65 | Placebo | NE | Death Before Measurement | 2 |
| LRN-12-6151 | <65 | Total | NE | Death Before Measurement | 3 |
| LRN-12-6153 | <65 | CMP123 | NE | Droped Study | 1 |
| LRN-12-6153 | <65 | Total | NE | Droped Study | 3 |
| LRN-12-6155 | >=65 | Placebo | NE | Withdrown Consent | 2 |
| LRN-12-6155 | >=65 | Total | NE | Withdrown Consent | 3 |
| LRN-12-6157 | <65 | CMP123 | NE | Withdrown Consent | 1 |
| LRN-12-6157 | <65 | Total | NE | Withdrown Consent | 3 |
| LRN-12-6159 | <65 | Placebo | PR |
| 2 |
| LRN-12-6159 | <65 | Total | PR |
| 3 |
| LRN-12-6161 | <65 | CMP123 | PR |
| 1 |
| LRN-12-6161 | <65 | Total | PR |
| 3 |
| LRN-12-6163 | <65 | Placebo | NE | Death Before Measurement | 2 |
| LRN-12-6163 | <65 | Total | NE | Death Before Measurement | 3 |
| LRN-12-6165 | >=65 | CMP123 | CR |
| 1 |
| LRN-12-6165 | >=65 | Total | CR |
| 3 |
I calculated unadjusted mean as below.
proc sql noprint;
select count (distinct usubjid) into : trtX from adrs2 where trtN = 1;
select count (distinct usubjid) into : trtY from adrs2 where trtN = 2;
select count (distinct usubjid) into : trtZ from adrs2 where trtN = 3;
%put &trtX &trtY &trtZ;
run;
proc freq data = adrs2;
tables trtN*agegr1/out=dummy (drop=percent);
tables avalc*trtN*agegr1 / out = adrs3 (drop=percent);
tables avalc*trtN*nereasn*agegr1 / out=utdtype (drop=percent);
run;
data adrs4 (drop=avalc nereasn) ;
length avalc $40.;
set adrs3 (in=a) utdtype (in=b);
by avalc;
if nereasn ne " " then _avalc = nereasn;
else if nereasn eq " " then _avalc = avalc;
rename _avalc = avalc;
run;
proc sort data=adrs4 out = adrs5 nodupkey;
by trtn count avalc;
run;
data adrs6;
set adrs5;
if trtN = 1 then denom = &trtX;
if trtN = 2 then denom = &trtY;
if trtN = 3 then denom = &trtZ;
percent = put ((count/denom)*100, 5.1);
CP = count||" ("||percent||")";
drop count denom percent;
run;
*_______________________________________________________________________________________________;
data ORR;
set adrs2;
if avalc in ("CR", "PR") then rate = 1;
else rate = 2;
run;
proc sort data=orr;
by agegr1 trtn;
run;
ods output OneWayFreqs = ORRfreq(rename = (frequency = count))
BinomialCLs = limit (where=(Type = "Clopper-Pearson (Exact)"))
BinomialTest = test;
proc freq data=orr order=formatted;
by agegr1 trtn;
tables rate/binomial(ac wilson exact) nocol norow nopercent;
run;
ods output close;
data limit2;
set limit;
CP = "("||strip(put(LowerCL,5.2))||", "||strip(put(UpperCL,5.2)) ||")";
keep agegr1 CP trtN;
run;
data orrfreq1;
set orrfreq;
if rate = 1 then do;
if trtN = 1 then denom = &trtX;
if trtN = 2 then denom = &trtY;
if trtN = 3 then denom = &trtZ;
CD = count||"/"||left(denom);
percent = put ((count/denom)*100, 5.1);
CP = strip (CD)||" ("||strip(percent)||"%)";
end;
if rate = 2 then delete;
keep agegr1 cp trtN;
run;
*_____________________________________________________________________________________________;
proc sort data=dummy out=dummy1 (keep=trtN agegr1) nodupkey; *to insert blank line for table;
by agegr1 trtN;
run;
proc sort data=adrs6 out=adrs7;
by agegr1 trtN;
run;
proc sort data=limit2 out=limit3;
by agegr1 trtN;
run;
proc sort data=orrfreq1 out=orrfreq2;
by agegr1 trtN;
run;
data adrs8;
length CP $50 avalc $50;
set adrs7 (in=a) dummy1 (in=b) orrfreq2 (in=c) limit3 (in=d);
by agegr1 trtN;
if b then do;
avalc = "BEST OVERALL RESPONSE";
end;
if c then do;
avalc = "OBJECTIVE RESPONSE RATE (1)";
end;
if d then do;
avalc = " (95% CI)";
end;
run;
data adrs9;
length avalc1 $ 50;
set adrs8;
if avalc = "BEST OVERALL RESPONSE" then do;
AVALC1 = "BEST OVERALL RESPONSE";
avaln = 1;
end;
if AVALC = "CR" then do
AVALC1 = "COMPLETE RESPONSE (CR)";
avaln =2;
end;
if AVALC = "PR" then do;
AVALC1 = "PARTIAL RESPONSE (PR)";
avaln =3;
end;
if AVALC = "SD" then do;
AVALC1 = "STABLE DISEASE (SD)";
avaln =4;
end;
if AVALC = "PD" then do;
AVALC1 = "PROGRESSIVE DISEASE (PD)";
avaln =5;
end;
if AVALC = "NE" then do;
AVALC1 = "UNABLE TO DETERMINE (UTD)";
avaln =6;
end;
if AVALC = "Death Before Measurement" then do;
AVALC1 = " REASON UTD 1";
avaln =7;
end;
if AVALC = "Droped Study" then do;
AVALC1 = " REASON UTD 2";
avaln =8;
end;
if AVALC = "Withdrown Consent" then do;
AVALC1 = " REASON UTD X";
avaln =9;
end;
if AVALC = "OBJECTIVE RESPONSE RATE (1)" then do;
AVALC1 = "OBJECTIVE RESPONSE RATE (1)";
avaln =91;
end;
if AVALC = " (95% CI)" then do;
AVALC1 = " (95% CI)";
avaln =92;
end;
drop avalc;
rename avalc1 = avalc;
RUN;
proc sort data = adrs9 out= adrs10;
by agegr1 avaln avalc;
run;
proc transpose data = adrs10 out = adrs11 (drop = _NAME_) prefix=TRT;
by agegr1 avaln avalc;
id trtN;
var cp;
run;
data adrs12;
set adrs11;
by agegr1;
if agegr1 = "<65" then agegr1n = 1;
else agegr1n = 2;
run;
data adrs13;
set adrs12;
if trt1 = " " and avalc ne "BEST OVERALL RESPONSE" then trt1 = " 00 (00.0)";
if trt2 = " " and avalc ne "BEST OVERALL RESPONSE" then trt2 = " 00 (00.0)";
if trt3 = " " and avalc ne "BEST OVERALL RESPONSE" then trt3 = " 00 (00.0)";
run;
Now, I have to calculate summary of adjusted mean of change from baseline viral load at week 12 and 16 by using proc mixed stage as factor and treatment.
Hello, @Aryyyan , specific instructions were given on how to present a portion of your data: https://blogs.sas.com/content/sastraining/2016/03/11/jedi-sas-tricks-data-to-data-step-macro/
Other questions have not been answered, such as what is wrong with your code now, and what "adjusted mean" do you want.
Echoing @PaigeMiller here, could you provide your definition of "adjusted" mean. I can think of several ways to adjust - subtract baseline, use baseline as a covariate, calculate marginal means to accommodate unequal sample sizes, weight factors in the model by (number of observations, 1/standard deviation, 1/variance, custom weights, any of these in conjunction with the first two). Since I am not really familiar with standards in this field, I don't know how to advise.you.
SteveDenham
SAS Innovate 2025 is scheduled for May 6-9 in Orlando, FL. Sign up to be first to learn about the agenda and registration!
ANOVA, or Analysis Of Variance, is used to compare the averages or means of two or more populations to better understand how they differ. Watch this tutorial for more.
Find more tutorials on the SAS Users YouTube channel.