Dear Michelle, Thank you for detailed description. I have red Phuse's documents, however I don't understand the mechanism between macro phase and data step especially... My final purpose was to check whether two period of date was overlapped or not. The script that I thought was following: %macro period(x1,y1,x2,y2); %if &x1 le &y2 and &x2 le &y1 %then %do; %if &x1 le &x2 %then %let start = &x2; %else %let st = &x1; %if &y1 le &y2 %then %let end = &y1; %else %let end = &y2; %let return = &&ed - &&st + 1; %end; &return %mend period; data aa; a1 = "2009/08/29"; a2 = "2009/09/29"; b1 = "2009/09/28"; b2 = "2009/10/29"; format c1 c2 c3 c4 yymmdd10.; c1 = input( a1, yymmdd10.); c2 = input( a2, yymmdd10.); c3 = input( b1, yymmdd10.); c4 = input( b2, yymmdd10.); x1 = %dupperiod(c1,c2,c3,c4); run; But it didn't work...so I thought to create more simple script, that was good approach at first. My desire of macro was: array a_start() a_start1-a_start10; array a_end() b_start() b_end() do i=1 to dim(); period&i = %period(a_starat, a_end, b_start, b_end); end; Best Regard,
... View more