Hi, I have added just one small logic and it worked fine...:) here is the code: data want(rename = (date = Monday)); format startDate endDate date date9. day $1.; keep date Sunday; reportDate="&month_run."d; endDate=intnx("day",reportDate,-1); startDate=intnx("month",reportDate,-6); date=startDate; do while (date<=endDate and i<400); i+1; day=" "; if weekday(date)=1 then day="M"; date=intnx("day",date,1); if day ne " " then output; Sunday = date+7; end; Format Sunday Date9.; run; Thanks all for your inputs and helping.
... View more