/*********************************************/ /*** DO NOT ALTER ANYTHING BELOW THIS LINE ***/ /*********************************************/ /* macro used to obtain recycled predictions */ %macro respect(); TITLE "Present PROC REG/STB estimates"; run; proc reg data=lib.&ds; model &outcome = &recycle &adjust /stb; run; /** Approach #1 - fix all indpendent variables other than the condition being predicted at the sample means **/ TITLE "Approach #1: GLM, estimates, and LSmeans follow.."; run; * get number of recycling variables; %let num_recv=%sysfunc(countw(&recycle)); proc glm data=lib.&ds; class &recycle; model &outcome = &recycle &adjust; %do i = 1 %to &num_recv; %do j = 1 %to &num_recv; /* use this form instead to cut out redundant terms: %do j = 1 %to &num_recv -1; */ %if &i ne &j %then %do; %let nv1 = %scan(&recycle, &i); /* nv1: 1st variable to estimate */ %let nv2 = %scan(&recycle, &j); /* nv2: 2nd variable to estimate */ estimate "&nv1 vs &nv2" &nv1 -1 1 &nv2 1 -1 ; /* estimate cross-products */ %end; %end; estimate "&nv1" &nv1 -1 1; /* get point estimate for NV1 */ %end; lsmeans &recycle /om stderr; run; quit; /***********************************************************************/ /** Approach #2: pick one condition and fix all other recycling vars to zero (keep adjusting vars at mean) **/ /* get 0's for use in building lsmeans statement in GLM (one less than total number of recycling vars */ %let zeros = ; %do k = 1 %to %eval(&num_recv -1); %let zeros = &zeros 0 ; %end; /** build a GLM for each recycling variable **/ %do ii = 1 %to &num_recv; /** initialize item you're keying in on (keyvar) and drop it from list of (remain)ing recycling vars for use in building GLM **/ %let keyvar =; %let remain =; %let keyvar = %scan(&recycle, &ii); %do jj = 1 %to &num_recv; %if &ii ne &jj %then %do; %let remain = &remain %scan(&recycle, &jj); %end; %end; TITLE1 "Approach #2: pick one condition (&keyvar) and fix all other"; TITLE2 "recycling vars to zero (keep adjusting vars at mean)"; run; proc glm data=lib.&ds; class &keyvar; model &outcome = &recycle &adjust; lsmeans &keyvar /at ( &remain ) = ( &zeros ) out=ls_remain; run; %end; %mend;