Reeza, thank you again for your code. Now, I want to use it on another occasion but I could not modify it very well.
I am using the following code to save the labels and print them above the tables in my report. In my SAS output, it works perfect and copies each label above each table (sample output below)
AGE: How old are you?
VarName
Mean
SD
L_95_p_CI
U_95_p_CI
N
AGE
39.88
14.25
39.14
40.62
1250
However, in my ODS WORD file, only the label for the first variable in the list appears. May you please help me to resolve this issue, please? Thanks
%macro do_sm(varname);
ods exclude all;
data output3;
retain VarName
VarLabel
Mean
&varname
LowerCLMean
UpperCLMean
N;
set output2;
run;
data output4 (rename=(VarName=VarName
VarLabel=Label
&varname=SD
LowerCLMean=L_95_p_CI
UpperCLMean=U_95_p_CI));
set output3;
run;
proc sql noprint;
select distinct Label into :title_name from output4;
quit;
data output5 (drop=Label); set output4; run;
ods exclude none;
title j=l "&title_name.";
proc print data=output5 noobs; run;
%mend do_sm;
ods word file="D:path\REPORT_&DATE..docx" STARTPAGE=NO;
OPTIONS NONUMBER NODATE FORMDLIM='~';
%do_sm(age);
%do_sm(money); ods word close;
... View more