data temp;
set temp;
retain countday 0;
do while (first_day<=last_day);
if weekday(input(first_day,yymmdd8.)) not in ('1' '7') then countday=countday+1;
first_day=first_day+1;
end;
run;
proc sql noprint;
select countday into :countday from temp;
quit;
/*获取今天所在月的月初到今天为止的工作日数*/
data temp;
set temp;
retain countday 0;
do while (first_day<=last_day);
/*双休日不参与统计计数*/
if weekday(input(first_day,yymmdd8.)) not in ('1' '7') then countday=countday+1;
first_day=first_day+1;
end;
run;
proc sql noprint;
/*将工作日数赋给宏变量countday*/
select countday into :countday from temp;
quit;