我有一个包含5个变量的表:
id year_beg year_end month_beg month_end
我想根据上一张表创建一个表格,其中包含年份/月份的年份/月份,表格与对象的持续时间匹配。
感谢您的帮助。
答案 0 :(得分:0)
<!DOCTYPE html>
Obs OBNO beg end
1 169330 36503 39778
2 169331 36501 39274
3 173535 36369 39511
4 173704 36424 39468
5 185348 36517 39630
6 186455 36658 39476
7 188162 36690 39344
8 190160 36767 39433
9 190164 36803 39469
10 192073 36803 39526
%macro corps;
%do annee = 1999 %to 2016;
%do mois = 1 %to 12;
proc sql;
create table out_&mois&annee as
select &annee as year, &mois as month, obno
from ent.Bornescontrat
having mdy(&mois,1,&annee) between beg and end or
(-1 + intnx("month",mdy(&mois,1,&annee),1)) between beg and end
;
quit;
%if &mois = 1 %then
%do;
data out_&annee;
set out_&mois&annee;
run;
%end;
%else
%do;
data out_&annee;
set out_&annee out_&mois&annee;
run;
%end;
proc sql;
drop table out_&mois&annee;
quit;
%end;
%if &annee = 1999 %then
%do;
data ent.out;
set out_&annee;
run;
%end;
%else
%do;
data ent.out;
set ent.out out_&annee;
run;
%end;
proc sql;
drop table out_&annee;
quit;
%end;
%mend;