What you provided looks like it kinda worked but for some reason it's just bringing in the same dates for the columns that are using it (for ex, for wbeg: 26JAN20 filled the column ; wend: 01FEB20 filled the column). Basically, in the end, I am trying to join a summarized data set to a detailed data set. I can't bring in AdmitDt as a field because it wont match onto the summarized data set. In the end, I will need variables that are using AdmitDt in their calculation (such as mend, wk1,wk2..) and using "&admitdt" instead of bringing the AdmitDt into the data is the only solution I can think of. Here is my code where the macro variable is being used:
data table2;
set table1;
format wbeg wend mbeg mend date8.;
AdmitDt = admitdt_1;
format AdmitDt mmddyy10.;
/* created macro to use in other steps without bringing in admitdt downstream*/
call symputx('admitdt',admitdt);
if &admitdt. >= '03sep2017'd and &admitdt. <= intnx('week',today(),-1,'e');
*Determine if a week shared between two months belongs to present month or the previous one;
mbeg= intnx('month',&admitdt.,0,'b');
mend= intnx('month',&admitdt.,0,'e');
wbeg = intnx('week',&admitdt.,0,'b');
wend = intnx('week',&admitdt.,0,'e');
madm = month(&admitdt.);
mwbeg = month(wbeg);
mwend = month(wend);
if month(wbeg) = month(wend) then do;
month3 = put(year(&admitdt.),4.)||put(month(&admitdt.),z2.);
end;
else if mend - wbeg < 7 then do;
if mend - wbeg < 3 then do;
if month(&admitdt.) = 12 then month3 = put(year(&admitdt.)+1,4.)||"01";
else month3 = put(year(&admitdt.),4.)||put(month(&admitdt.)+1,z2.);
end;
else month3 = put(year(&admitdt.),4.)||put(month(&admitdt.),z2.);
end;
else if wend - mbeg < 7 then do;
if wend - mbeg < 3 then do;
if month(&admitdt.) = 1 then month3 = put(year(&admitdt.) - 1,4.) || "12";
else month3 = put(year(&admitdt.),4.)||put(month(&admitdt.)-1,z2.);
end;
else month3 = put(year(&admitdt.),4.)||put(month(&admitdt.),z2.);
end;
... View more