1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75
|
data test_201701;
input id;
cards;
2
1
3
;
run;
data test_201702;
input id;
cards;
1
6
5
;
run;
data test_201703;
input id;
cards;
1
4
5
;
run;
data test_201801;
input id;
cards;
1
4
5
;
run;
option symbolgen mprint mlogic;
%macro tt(date_deb=,date_fin=);
%do i=0 %to %sysfunc(intck(month, %sysfunc(inputn(&date_deb,yymmn6.)), %sysfunc(inputn(&date_fin,yymmn6..)) ));
%if %sysfunc(exist(test_%sysfunc(putn(%sysfunc(intnx(month,%sysfunc(inputn(&date_deb,yymmn6.)),&i)),yymmn6.)))) %then %do;
proc sort data =test_%sysfunc(putn(%sysfunc(intnx(month,%sysfunc(inputn(&date_deb,yymmn6.)),&i)),yymmn6.));
by id;
run;
%end;
%end;
data fin;
merge %do i=0 %to %sysfunc(intck(month, %sysfunc(inputn(&date_deb,yymmn6.)), %sysfunc(inputn(&date_fin,yymmn6..)) ));
%if %sysfunc(exist(test_%sysfunc(putn(%sysfunc(intnx(month,%sysfunc(inputn(&date_deb,yymmn6.)),&i)),yymmn6.)))) %then %do;
test_%sysfunc(putn(%sysfunc(intnx(month,%sysfunc(inputn(&date_deb,yymmn6.)),&i)),yymmn6.))
%end;
%end
;;
by id ;
run;
%mend tt;
%tt(date_deb=201701,date_fin=201801); |
Partager