Hello @Rezza, I tried to implement your foregoing articles and I think I still need to decrease some steps to build desired dynamic structures. 1st -> I need to give parametric value instead of 3 in the following statement “%Do i=1 %To 3;” but question mark in my mind is how can I determine this value being a parametric.how can I know this value? 2nd-> I need to enhance the following statement values(1,4,7) being a parametric “Intnx("Month", "&StartDate"d, 1, "E");, Intnx("Month", "&StartDate"d, 4, "E");, Intnx("Month", "&StartDate"d, 7, "E"); Then it will probably seem proper, what do you think @Reeza? %Let StartDate=31JUL1989;
%Let EndDate=28FEB1990;
Data Have;
Format Pro_End_Date_Ym DATE9.;
Infile Datalines Missover;
Input Pro_End_Date_Ym;
Datalines;
10826
10827
10828
10829
10830
10850
10870
10880
10991
10999
;
Run;
Options Mprint;
%Macro New;
Data Want;
Set Have;
Length Period 4.;
Period = 0;
%Do i=1 %To 3;
%If &i.=1 %Then %Do;
Boundary&i. = "&StartDate"D;
Boundary%Eval(&i.+1) = Intnx("Month", "&StartDate"d, 1, "E");
%End;
%If &i.=2 %Then %Do;
Boundary&i. = Intnx("Month", "&StartDate"d, 1, "E");
Boundary%Eval(&i.+1) = Intnx("Month", "&StartDate"d, 4, "E");
%End;
%If &i.=3 %Then %Do;
Boundary&i. = Intnx("Month", "&StartDate"d, 4, "E");
Boundary%Eval(&i.+1) = Intnx("Month", "&StartDate"d, 7, "E");
%End;
Format Boundary: Date9.;
%If &i.=1 %Then %Do;
If Boundary&i. <= PRO_END_DATE_YM <= Boundary%Eval(&i.+1) Then Period =&i.;
%End;
%Else %Do;
If Boundary&i. < PRO_END_DATE_YM <= Boundary%Eval(&i.+1) Then Period =&i.;
%End;
%End;
Run;
%Mend New;
%New; But I just realized one thing, you used “1” value in your-> “Intnx("Month", "&StartDate"d, 1, "E"); “ statement because there is just one month between 31JUL1989 and 31AUG1989. What if Start Date is given being a 31JUN1989 then it should be Intnx("Month", "&StartDate"d, 2, "E"); and continue like -> Intnx("Month", "&StartDate"d, 5, "E");, Intnx("Month", "&StartDate"d, 8, "E"); So how can I provide this kind of dynamic structure over your code?
... View more