I'm writing a macro where it creates date flags for different variables in my dataset. Some of the variables have an associated year variable (var_YYYY) and some don't. So in my call, I add another parameter to note if there is a year variable (yrvar= 1 or 2). I then wrote an if/then/do statement that is supposed to only perform the data step if yrvar is 1 or 2. But when I run the first call, even though yrvar has a value of 2, I still get the note saying EN_&var2._YYYY is uninitialized. Why is it even performing the task in red if yrvar=2 in the call? %macro days(var1,var2,res,yrvar); data dates2; set dates; where EN_&var1. in (&res.); if EN_&var2._MM in (1,2,3,4,5,6,7,8,9,10,11,12) then EN_&var1._MOFLAG=1; else EN_&var1._MOFLAG=0; **month y/n**; if &yrvar. = 1 then do; if EN_&var2._YYYY in (2010,2011,2012) then EN_&var1._YRFLAG=1; else EN_&var1._YRFLAG=0; **year y/n**; if EN_&var1._MOFLAG=1 and EN_&var1._YRFLAG=1 then EN_&var1._SDFLAG=1; else EN_&var1._SDFLAG=0; **start date y/n**; end; else if &yrvar. = 2 then do; if EN_&var1._MOFLAG=1 then EN_&var1._SDFLAG=1; else EN_&var1._SDFLAG=0; **start date y/n**; end; run; %mend days; %days(B9A1_YN,B9A2B,1,2); %days(B9A6C_YN,B9A6D2,1,1);
... View more