Morning,
I hope I am posting this in the right section. I am using ods pdf to generate a report and want to conditionally execute some proc report statements based on macro variables. I have wrapped the proc reports in a macro and am using %if %then %else to direct the printing.
The issue I am running into is that my last %else condition is not executing in the output. The log shows that the macro logic worked as it should but the actual PDF file is missing the table that was supposed to print.
I have included the below code (with comments - hopefully it is clear) and log:
%macro grpprint / mindelimiter=',';
%*For Standard or Data request types include value of &groupdefine as an ods text line,
further, print either grpstdcdrcp2 or grpstdcts table depending on the &groupdefine value;
%if &reqapp in (Standard,Data) %then %do;
ods region x = 0.50 in
y = 1.50 in;
ods text = "^{style[font_face='arial' fontsize=10pt]Participants grouped by: &groupdefine}";
%*if Standard or Data request type and &groupdefine is one of two values below, print grpstdcdrcp2;
%if &groupdefine in (Final Clinical Diagnosis,Pathological Diagnosis) %then %do;
options linesize=256;
ods region x = 0.50 in
y = 1.75 in
width = 7.25 in;
proc report data=grpstdcdrcp2 nowd style={just=l};
column ptcdxcat1 ptcdxnum1 ptcgold ptcnumpt1 ptcinex1;
define ptcdxcat1 / display 'Dx category'
style(column)={cellwidth=1.20in};
define ptcdxnum1 / display 'Dx numbers (click for labels)'
style(header)={url="&dxlink" color=blue textdecoration=underline}
style(column)={cellwidth=1.20in};
define ptcgold / display 'GOLD stage'
style(column)={cellwidth=1.20in};
define ptcnumpt1 / display 'Participants required'
style(column)={cellwidth=1.20in};
define ptcinex1 / display "Other inclusion & exclusion"
style(column)={cellwidth=2.00in};
run;
%end;
%*otherwise if Standard or Data request type and &groupdefine is value below, print grpstdcts;
%else %if &groupdefine = Radiological Diagnosis %then %do;
options linesize=256;
ods region x = 0.50 in
y = 1.75 in
width = 7.25 in;
proc report data=grpstdcts nowd style={just=l};
column ptcdxnum2 ptcnumpt2 ptcinex2;
define ptcdxnum2 / display 'Dx numbers (click for labels)'
style(header)={url="&dxlink" color=blue textdecoration=underline}
style(column)={cellwidth=1.25in};
define ptcnumpt2 / display 'Participants required'
style(column)={cellwidth=1.25in};
define ptcinex2 / display 'Other inclusion/exclusion'
style(column)={cellwidth=2.00in};
run;
%end;
%end;
%*otherwise if Express request type, do not execute the above and instead print the grpexp table;
%else %if &reqapp=Express %then %do;
options linesize=256;
ods region x = 0.50 in
y = 1.50 in
width = 7.25 in;
proc report data=grpexp nowd style={just=l};
column ptcdisgrp ptcdissev ptcnumpt3;
define ptcdisgrp / display 'Disease group'
style(column)={cellwidth=1.25in};
define ptcdissev / display 'Disease severity'
style(column)={cellwidth=1.25in};
define ptcnumpt3 / display 'Participants required'
style(column)={cellwidth=1.25in};
run;
%end;
%mend grpprint;
%grpprint;
Log:
2988 %macro grpprint / mindelimiter=',';
2989
2990 %*For Standard or Data request types include value of &groupdefine as an ods text line,
2991 further, print either grpstdcdrcp2 or grpstdcts table depending on the &groupdefine value;
2992 %if &reqapp in (Standard,Data) %then %do;
2993 ods region x = 0.50 in
2994 y = 1.50 in;
2995 ods text = "^{style[font_face='arial' fontsize=10pt]Participants grouped by: &groupdefine}";
2996
2997 %*if Standard or Data request type and &groupdefine is one of two values below, print grpstdcdrcp2;
2998 %if &groupdefine in (Final Clinical Diagnosis,Pathological Diagnosis) %then %do;
2999 options linesize=256;
3000 ods region x = 0.50 in
3001 y = 1.75 in
3002 width = 7.25 in;
3003
3004 proc report data=grpstdcdrcp2 nowd style={just=l};
3005 column ptcdxcat1 ptcdxnum1 ptcgold ptcnumpt1 ptcinex1;
3006 define ptcdxcat1 / display 'Dx category'
3007 style(column)={cellwidth=1.20in};
3008
3009 define ptcdxnum1 / display 'Dx numbers (click for labels)'
3010 style(header)={url="&dxlink" color=blue textdecoration=underline}
3011 style(column)={cellwidth=1.20in};
3012
3013 define ptcgold / display 'GOLD stage'
3014 style(column)={cellwidth=1.20in};
3015
3016 define ptcnumpt1 / display 'Participants required'
3017 style(column)={cellwidth=1.20in};
3018
3019 define ptcinex1 / display "Other inclusion & exclusion"
3020 style(column)={cellwidth=2.00in};
3021 run;
3022 %end;
3023
3024 %*otherwise if Standard or Data request type and &groupdefine is value below, print grpstdcts;
3025 %else %if &groupdefine = Radiological Diagnosis %then %do;
3026 options linesize=256;
3027 ods region x = 0.50 in
3028 y = 1.75 in
3029 width = 7.25 in;
3030 proc report data=grpstdcts nowd style={just=l};
3031 column ptcdxnum2 ptcnumpt2 ptcinex2;
3032 define ptcdxnum2 / display 'Dx numbers (click for labels)'
3033 style(header)={url="&dxlink" color=blue textdecoration=underline}
3034 style(column)={cellwidth=1.25in};
3035 define ptcnumpt2 / display 'Participants required'
3036 style(column)={cellwidth=1.25in};
3037 define ptcinex2 / display 'Other inclusion/exclusion'
3038 style(column)={cellwidth=2.00in};
3039 run;
3040 %end;
3041 %end;
3042
3043 %*otherwise if Express request type, do not execute the above and instead print the grpexp table;
3044 %else %if &reqapp=Express %then %do;
3045 options linesize=256;
3046 ods region x = 0.50 in
3047 y = 1.50 in
3048 width = 7.25 in;
3049
3050 proc report data=grpexp nowd style={just=l};
3051 column ptcdisgrp ptcdissev ptcnumpt3;
3052 define ptcdisgrp / display 'Disease group'
3053 style(column)={cellwidth=1.25in};
3054
3055 define ptcdissev / display 'Disease severity'
3056 style(column)={cellwidth=1.25in};
3057
3058 define ptcnumpt3 / display 'Participants required'
3059 style(column)={cellwidth=1.25in};
3060
3061 run;
3062 %end;
3063 %mend grpprint;
3064 %grpprint;
MLOGIC(GRPPRINT): Beginning execution.
SYMBOLGEN: Macro variable REQAPP resolves to Express
MLOGIC(GRPPRINT): %IF condition &reqapp in (Standard,Data) is FALSE
SYMBOLGEN: Macro variable REQAPP resolves to Express
MLOGIC(GRPPRINT): %IF condition &reqapp=Express is TRUE
MPRINT(GRPPRINT): options linesize=256;
MPRINT(GRPPRINT): ods region x = 0.50 in y = 1.50 in width = 7.25 in;
MPRINT(GRPPRINT): proc report data=grpexp nowd style={just=l};
MPRINT(GRPPRINT): column ptcdisgrp ptcdissev ptcnumpt3;
MPRINT(GRPPRINT): define ptcdisgrp / display 'Disease group' style(column)={cellwidth=1.25in};
MPRINT(GRPPRINT): define ptcdissev / display 'Disease severity' style(column)={cellwidth=1.25in};
MPRINT(GRPPRINT): define ptcnumpt3 / display 'Participants required' style(column)={cellwidth=1.25in};
MPRINT(GRPPRINT): run;
NOTE: There were 2 observations read from the data set WORK.GRPEXP.
NOTE: PROCEDURE REPORT used (Total process time):
real time 0.01 seconds
cpu time 0.01 seconds
MLOGIC(GRPPRINT): Ending execution.
The macro debug code in the log at line 3064 seems to indicate that the value of &reqapp resolved to Express and that my %if &reqapp=Express is TRUE. I then see that the proc report read 2 observations; however, as mentioned above, the output PDF file does not contain the results of the proc report. I have tested the hard code and run the macro with &reqapp evaluated as Standard or Data and everything works perfectly. I have also tried isolating the 'Express' portion within the grpprint macro and it works fine, e.g.:
%macro grpprint / mindelimiter=',';
%*if Express request type, print the grpexp table;
%if &reqapp=Express %then %do;
options linesize=256;
ods region x = 0.50 in
y = 1.50 in
width = 7.25 in;
proc report data=grpexp nowd style={just=l};
column ptcdisgrp ptcdissev ptcnumpt3;
define ptcdisgrp / display 'Disease group'
style(column)={cellwidth=1.25in};
define ptcdissev / display 'Disease severity'
style(column)={cellwidth=1.25in};
define ptcnumpt3 / display 'Participants required'
style(column)={cellwidth=1.25in};
run;
%end;
Is there something wrong with my %if %do %else logic? Am I trying to do too much within one macro?
Thanks,
Lucas
... View more