BookmarkSubscribeRSS Feed
🔒 This topic is solved and locked. Need further help from the community? Please sign in and ask a new question.
JorgeHidalgo
Calcite | Level 5

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;

1 ACCEPTED SOLUTION

Accepted Solutions
FreelanceReinh
Jade | Level 19

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.

  • Option 1: Look up the name(s) in the procedure documentation, typically under Details --> ODS Table Names. Here is the link for PROC GLM: ODS Table Names.
  • Option 2: Let SAS display the names (in the log window) in a preliminary test run of the PROC step (possibly with only a few observations of the input dataset in order to avoid long processing times) using ODS trace on;

 

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.

 

View solution in original post

2 REPLIES 2
FreelanceReinh
Jade | Level 19

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.

  • Option 1: Look up the name(s) in the procedure documentation, typically under Details --> ODS Table Names. Here is the link for PROC GLM: ODS Table Names.
  • Option 2: Let SAS display the names (in the log window) in a preliminary test run of the PROC step (possibly with only a few observations of the input dataset in order to avoid long processing times) using ODS trace on;

 

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.

 

JorgeHidalgo
Calcite | Level 5

That is working perfectly, I really appreciate your time, this was exactly that I needed.

 

Jorge

Best Wishes

sas-innovate-2024.png

Available on demand!

Missed SAS Innovate Las Vegas? Watch all the action for free! View the keynotes, general sessions and 22 breakouts on demand.

 

Register now!

How to Concatenate Values

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.

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
  • 2 replies
  • 589 views
  • 0 likes
  • 2 in conversation