@Denali wrote:
Hi @ballardw ,
The code worked, but the variables are ordered from A to Z. Is there a way that we can order them by the original order?
Also, I was running another set of macro for all the continuous variables (previous code was for categorical variables with class statement). When I exported the ORs and 95% CIs, why all the ORs and 95% CIs from the categorical variables were all included in the Excel file even I changed the name of the file? Is there a way that I can export all the continuous variables in a seperate Excel file?
Please see my code for continuous variables below:
%macro IP1(x=); ods select cloddswald; ods output cloddswald=odds_&x.;
proc logistic data = CP1; model improve = &x. /rl; run; %mend IP1;
%IP1(x=Age); %IP1(x=Pre_Score);
ods excel close;
data toprint1; length effect $ 40; set odds_: ; run;
ods excel file="H:\Data\CI_Continuous.xlsx" options(sheet_interval='NONE');
proc print data=toprint1; run;
ods excel close;
Thank you!
Manually write out the names of the data sets on the set statement in the Toprint data step in the order you want them.
Or provide variable names that sort in the order you want the output.
Or instead of using the variable name to name the odds_ set provide an order macro variable so the Odds_ sets will sort as desired
%macro IP(x=,order=);
ods select cloddswald;
ods output cloddswald=odds_&order.;
proc logistic data = CP1;
class &x.;
model improve = &x. /rl;
run;
%mend IP;
%IP(x=Age_C, order=01);
%IP(x=Gender, order=02); data toprint; set odds_01 - odds_02; run;
If you use numbers as shown you cannot skip any unless you make some more sublists at which point you might as well go the "name all the sets in the order desired"
... View more