Hi all, I am facing a problem of my if statement is not work in the Do loop. This cause my ods html does not work and I cant print out my result. Did I type anything wrong?
The log summary does not have any error. But just the result does not printed out.
%macro date(YYYY=2019,MM=02,Y=2019,M=02);%global YR accyrfy MTH accmthfy acmthfy1 acmthfy2 fileyear accyrfy1 filemth;
libname pl&Y&M. "\\kaiwksgh415thw5\Data\POLA\Claim\&Y\&Y&M\DBF";
Data pl&Y&M..POLA_clm_3months_&Y&M.;
set pl&Y&M..POLA_clm_agg_&Y&M.;
.........................................(BODY)
%macro financial (MONTH);
%do i=&acmthfy1. %to &MONTH;
%if &i.=1 %THEN %DO;
%let filemth=12;
%end;
%else %if &i.=12 %then %do;
%let filemth=11;
%end;
%else %if &i.=11 %then %do;
%let filemth=10;
%end;
%else %do;
%let filemth=0%eval(&i.-1);
%end;
/*****************************PD*****************************/
PROC SQL;
create table SMCD_PD_&fileyear&filemth. AS
SELECT put(zmajrsk,$class.) as class, dev11yr_fy,sum(zclmpd) AS zclmpd
FROM pl&Y&M..POLA_clm_3months_&Y&M.
WHERE ACCYR_FY=&accyrfy1. & accmth_fy=&i.
GROUP BY class,2;
run;
ods html
file="\\kaiwksgh415thw5\Data\POLA\Claim\&fileyear\&fileyear&filemth\result\SMCD_mth_PD_FY_10DY_&fileyear&filemth..html"
style=normal;
proc print;
run;
%end;
%mend financial;
%financial(&acmthfy2.);
%mend date;
%date(YYYY=2019,MM=02,Y=2019,M=02);
run;
The "inner" (keep in mind that nested/hierarchical macro definitions are not possible in SAS, all macros exist in the global symbol table) macro definition for financial() has no real purpose; you only call it once with one parameter.
Remove that definition (and call), and code your %do with the real parameter:
%do i=&acmthfy1. %to &acmthfy2.;
Add %put statements to reveal the state of your macro variables at critical stages.
Make your calculation of filemth simpler:
%if i = 1
%then %let filemth=12;
%else %let filemth=%sysfunc(putn(&i.-1,z2.));
Join us for SAS Innovate 2025, our biggest and most exciting global event of the year, in Orlando, FL, from May 6-9. Sign up by March 14 for just $795.
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.
Ready to level-up your skills? Choose your own adventure.