Thank you so much for the time, I am running a proc glm analysis and I want to do an operation with a specific output, i.e. I want to summing the SS of rep factor and ABC interaction in a confounding design, How Can I do that? Heres is my code?
I would like to know the way to define this specific terms before running the model, my option now is running the program and put the actual value, however I have to wait for running the program.
/*Jorge Angel Hidalgo-Confounding Poultry Manure Example*/
dm 'output;clear;log;clear';
options ls=72 formdlim='';
ods graphics off;
ods html close;
ods listing;
title 'Confounding-Poultry Manure Example-Jorge Angel Hidalgo';
data one;
do block=1 to 6;
do s=1 to 4;
input a b c y@@;
output;
end;
end;
datalines;
0 1 1 48.81 1 1 0 58.88 1 0 1 46.11 0 0 0 38.62
1 0 0 40.49 1 1 1 61.55 0 0 1 32.75 0 1 0 55.07
1 1 0 50.43 0 0 0 40.26 1 0 1 52.31 0 1 1 49.62
0 0 1 32.36 1 1 1 48.49 1 0 0 51.94 0 1 0 53.86
1 0 1 39.30 1 1 0 49.93 0 0 0 39.23 0 1 1 51.43
0 1 0 47.37 0 0 1 37.25 1 1 1 46.87 1 0 0 46.94
;
proc print data=one;
run;
proc glm data=one;
class block a b c;
model y=block a b a*b c a*c b*c/ss3;
run;
data two;
do rep=1 to 3;
do block=2*rep-1 to 2*rep;
do s=1 to 4;
input a b c y@@;
output;
end;
end;
end;
datalines;
0 1 1 48.81 1 1 0 58.88 1 0 1 46.11 0 0 0 38.62
1 0 0 40.49 1 1 1 61.55 0 0 1 32.75 0 1 0 55.07
1 1 0 50.43 0 0 0 40.26 1 0 1 52.31 0 1 1 49.62
0 0 1 32.36 1 1 1 48.49 1 0 0 51.94 0 1 0 53.86
1 0 1 39.30 1 1 0 49.93 0 0 0 39.23 0 1 1 51.43
0 1 0 47.37 0 0 1 37.25 1 1 1 46.87 1 0 0 46.94
;
proc glm data=two;
class rep a b c;
model y=rep a|b|c/ss3;
run;
title3 "Calculating (Rep*ABC) SS";
data three;
abcSS=??
repSS=??
bksSS=??
Rep*ABC=bksSS-repSS-abcSS;
proc print data=three;
run;
quit;
Hello @JorgeHidalgo and welcome to the SAS Support Communities!
Would you like to perform calculations with selected values (such as sums of squares) that you see in procedure output without the need to copy and paste from the output window to the program editor?
If so, you can use ODS output datasets.
Example: You see PROC GLM output, but you don't know the names of the ODS output datasets.
ods trace on;
proc glm data=one;
class block a b c;
model y=block a b a*b c a*c b*c/ss3;
quit;
ods trace off;
Let's assume that ModelANOVA is the table you're interested in. Then you'd request this ODS output dataset with an ODS OUTPUT statement:
ods output ModelANOVA=ssb; /* ssb=arbitrary dataset name */
proc glm data=one;
class block a b c;
model y=block a b a*b c a*c b*c/ss3;
quit;
proc print data=ssb width=min;
run;
ods output ModelANOVA=ss;
proc glm data=two;
class rep a b c;
model y=rep a|b|c/ss3;
quit;
proc print data=ss width=min;
run;
(In some cases PROC CONTENTS, e.g. proc contents data=ss; run; can be useful to clarify variable types.)
Now that you've created the ODS output datasets (here: SSB and SS) you can work with them as with any other datasets, e.g.:
data want;
set ssb(where=(source='block') keep=source ss rename=(ss=ss_block));
set ss(where=(source='rep') keep=source ss rename=(ss=ss_rep));
set ss(where=(source='a*b*c') keep=source ss rename=(ss=ss_abc));
/* < perform calculations involving ss_block, ss_rep and ss_abc here > */
drop source;
run;
Please adapt the above example to your needs.
Hello @JorgeHidalgo and welcome to the SAS Support Communities!
Would you like to perform calculations with selected values (such as sums of squares) that you see in procedure output without the need to copy and paste from the output window to the program editor?
If so, you can use ODS output datasets.
Example: You see PROC GLM output, but you don't know the names of the ODS output datasets.
ods trace on;
proc glm data=one;
class block a b c;
model y=block a b a*b c a*c b*c/ss3;
quit;
ods trace off;
Let's assume that ModelANOVA is the table you're interested in. Then you'd request this ODS output dataset with an ODS OUTPUT statement:
ods output ModelANOVA=ssb; /* ssb=arbitrary dataset name */
proc glm data=one;
class block a b c;
model y=block a b a*b c a*c b*c/ss3;
quit;
proc print data=ssb width=min;
run;
ods output ModelANOVA=ss;
proc glm data=two;
class rep a b c;
model y=rep a|b|c/ss3;
quit;
proc print data=ss width=min;
run;
(In some cases PROC CONTENTS, e.g. proc contents data=ss; run; can be useful to clarify variable types.)
Now that you've created the ODS output datasets (here: SSB and SS) you can work with them as with any other datasets, e.g.:
data want;
set ssb(where=(source='block') keep=source ss rename=(ss=ss_block));
set ss(where=(source='rep') keep=source ss rename=(ss=ss_rep));
set ss(where=(source='a*b*c') keep=source ss rename=(ss=ss_abc));
/* < perform calculations involving ss_block, ss_rep and ss_abc here > */
drop source;
run;
Please adapt the above example to your needs.
That is working perfectly, I really appreciate your time, this was exactly that I needed.
Jorge
Best Wishes
Are you ready for the spotlight? We're accepting content ideas for SAS Innovate 2025 to be held May 6-9 in Orlando, FL. The call is open until September 25. Read more here about why you should contribute and what is in it for you!
Learn how use the CAT functions in SAS to join values from multiple variables into a single value.
Find more tutorials on the SAS Users YouTube channel.