- period.sas7bdat
我的思路是:第一步先建7个dummy, 所有值为缺失; 第二步是根据设定的时间条件来替换那些缺失值。
*step 1: create 7 dummy varialbes with missing value;
data bbb (DROP = i);
set period;
array A {*} period_1 - period_7;
do i = 1 to 7;
A(i) = . ;
end;
run;
*step 2: replace all missing values accoring to different time conditions;
%macro perioddummy;
%do count = 1 %to 7;
data ccc;
set bbb;
if (1993 + &count) <= year <= (1995 + &count) then period_&count=0;
else if (1996 + &count) <= year <= (1998 + &count) then period_&count=1;
else period_&count=2;
run;
%end;
%mend;
%perioddummy;