I have a table having one column named: Primary_coverage as shown below,
Primary_coverage |
combined single limit |
uninsured motorist |
Medical |
Bodily Injury |
I want to creat a macro to loop through Year, Quarter, Month and column value dynamically,so that my table value should look as shown below: (2000Q1 to 2002Q4=36 months, 12 quarters, 3 years)
Earliest year will always begin at 2000Q1
year | quarter | Primary_coverage | months |
2000 | 1 | combined single limit | 36 |
2000 | 2 | combined single limit | 33 |
2000 | 3 | combined single limit | 30 |
2000 | 4 | combined single limit | 27 |
2001 | 1 | combined single limit | 24 |
2001 | 2 | combined single limit | 21 |
2001 | 3 | combined single limit | 18 |
2001 | 4 | combined single limit | 15 |
2002 | 1 | combined single limit | 12 |
2002 | 2 | combined single limit | 9 |
2002 | 3 | combined single limit | 6 |
2002 | 4 | combined single limit | 3 |
2000 | 1 | uninsured motorist | 36 |
2000 | 2 | uninsured motorist | 33 |
2000 | 3 | uninsured motorist | 30 |
2000 | 4 | uninsured motorist | 27 |
2001 | 1 | uninsured motorist | 24 |
2001 | 2 | uninsured motorist | 21 |
2001 | 3 | uninsured motorist | 18 |
2001 | 4 | uninsured motorist | 15 |
2002 | 1 | uninsured motorist | 12 |
2002 | 2 | uninsured motorist | 9 |
2002 | 3 | uninsured motorist | 6 |
2002 | 4 | uninsured motorist | 3 |
2000 | 1 | Medical | 36 |
2000 | 2 | Medical | 33 |
2000 | 3 | Medical | 30 |
2000 | 4 | Medical | 27 |
2001 | 1 | Medical | 24 |
2001 | 2 | Medical | 21 |
2001 | 3 | Medical | 18 |
2001 | 4 | Medical | 15 |
2002 | 1 | Medical | 12 |
2002 | 2 | Medical | 9 |
2002 | 3 | Medical | 6 |
2002 | 4 | Medical | 3 |
2000 | 1 | Bodily Injury | 36 |
2000 | 2 | Bodily Injury | 33 |
2000 | 3 | Bodily Injury | 30 |
2000 | 4 | Bodily Injury | 27 |
2001 | 1 | Bodily Injury | 24 |
2001 | 2 | Bodily Injury | 21 |
2001 | 3 | Bodily Injury | 18 |
2001 | 4 | Bodily Injury | 15 |
2002 | 1 | Bodily Injury | 12 |
2002 | 2 | Bodily Injury | 9 |
2002 | 3 | Bodily Injury | 6 |
2002 | 4 | Bodily Injury | 3 |
BUT When I RUN the SAME PROGRAM ON 2003Q2 My table should look as shown below: (2000Q1 to 2003Q2=42 months,14 Quarters, 3 years)
year | quarter | Primary_coverage | months |
2000 | 1 | combined single limit | 42 |
2000 | 2 | combined single limit | 39 |
2000 | 3 | combined single limit | 36 |
2000 | 4 | combined single limit | 33 |
2001 | 1 | combined single limit | 30 |
2001 | 2 | combined single limit | 27 |
2001 | 3 | combined single limit | 24 |
2001 | 4 | combined single limit | 21 |
2002 | 1 | combined single limit | 18 |
2002 | 2 | combined single limit | 15 |
2002 | 3 | combined single limit | 12 |
2002 | 4 | combined single limit | 9 |
2003 | 1 | combined single limit | 6 |
2003 | 2 | combined single limit | 3 |
2000 | 1 | uninsured motorist | 42 |
2000 | 2 | uninsured motorist | 39 |
2000 | 3 | uninsured motorist | 36 |
2000 | 4 | uninsured motorist | 33 |
2001 | 1 | uninsured motorist | 30 |
2001 | 2 | uninsured motorist | 27 |
2001 | 3 | uninsured motorist | 24 |
2001 | 4 | uninsured motorist | 21 |
2002 | 1 | uninsured motorist | 18 |
2002 | 2 | uninsured motorist | 15 |
2002 | 3 | uninsured motorist | 12 |
2002 | 4 | uninsured motorist | 9 |
2003 | 1 | uninsured motorist | 6 |
2003 | 2 | uninsured motorist | 3 |
2000 | 1 | Medical | 42 |
2000 | 2 | Medical | 39 |
2000 | 3 | Medical | 36 |
2000 | 4 | Medical | 33 |
2001 | 1 | Medical | 30 |
2001 | 2 | Medical | 27 |
2001 | 3 | Medical | 24 |
2001 | 4 | Medical | 21 |
2002 | 1 | Medical | 18 |
2002 | 2 | Medical | 15 |
2002 | 3 | Medical | 12 |
2002 | 4 | Medical | 9 |
2003 | 1 | Medical | 6 |
2003 | 2 | Medical | 3 |
2000 | 1 | Bodily Injury | 42 |
2000 | 2 | Bodily Injury | 39 |
2000 | 3 | Bodily Injury | 36 |
2000 | 4 | Bodily Injury | 33 |
2001 | 1 | Bodily Injury | 30 |
2001 | 2 | Bodily Injury | 27 |
2001 | 3 | Bodily Injury | 24 |
2001 | 4 | Bodily Injury | 21 |
2002 | 1 | Bodily Injury | 18 |
2002 | 2 | Bodily Injury | 15 |
2002 | 3 | Bodily Injury | 12 |
2002 | 4 | Bodily Injury | 9 |
2003 | 1 | Bodily Injury | 6 |
2003 | 2 | Bodily Injury | 3 |
It looks like your last year may end mid-year.
Does your earliest year always begin with Q1, or could it begin midway through the year?
OK, this would probably do it:
%macro test (outdata=, end_year=, end_q=);
%local months;
%let months = %eval(12 * (&end_year - 1999));
%if &end_q=3 %then %let months = %eval(&months-3);
%else %if &end_q=2 %then %let months = %eval(&months-6);
%else %if &end_q=1 %then %let months = %eval(&months-9);
data &outdata;
length year quarter 8;
length primary_coverage $ 21;
length months 8;
do Primary_coverage='combined single limit', 'uninsured motorist', 'Medical', 'Bodily injury';
months = &months;
do year=2000 to &end_year;
do quarter=1 to 4;
if year < &end_year or quarter <= &end_q then output;
months = months-3;
end;
end;
end;
run;
%mend test;
%test (outdata=_2003_q2, end_year=2003, end_q=2)
proc print;
run;
I have a table having one column named: Primary_coverage (having 2observations) as shown below,
Primary_coverage |
combined single limit |
uninsured motorist |
I want to creat a macro to loop through Year, Quarter, Month and column value dynamically,so that my table value should look as shown below: (2000Q1 to 2002Q4=36 months, 12 quarters, 3 years)
Earliest year will always begin at 2000Q1
year | quarter | Primary_coverage | months |
2000 | 1 | combined single limit | 3 |
2000 | 1 | combined single limit | 6 |
2000 | 1 | combined single limit | 9 |
2000 | 1 | combined single limit | 12 |
2000 | 1 | combined single limit | 15 |
2000 | 1 | combined single limit | 18 |
2000 | 1 | combined single limit | 21 |
2000 | 1 | combined single limit | 24 |
2000 | 1 | combined single limit | 27 |
2000 | 1 | combined single limit | 30 |
2000 | 1 | combined single limit | 33 |
2000 | 1 | combined single limit | 36 |
2000 | 2 | combined single limit | 3 |
2000 | 2 | combined single limit | 6 |
2000 | 2 | combined single limit | 9 |
2000 | 2 | combined single limit | 12 |
2000 | 2 | combined single limit | 15 |
2000 | 2 | combined single limit | 18 |
2000 | 2 | combined single limit | 21 |
2000 | 2 | combined single limit | 24 |
2000 | 2 | combined single limit | 27 |
2000 | 2 | combined single limit | 30 |
2000 | 2 | combined single limit | 33 |
2000 | 2 | combined single limit | 36 |
2000 | 3 | combined single limit | 3 |
2000 | 3 | combined single limit | 6 |
2000 | 3 | combined single limit | 9 |
2000 | 3 | combined single limit | 12 |
2000 | 3 | combined single limit | 15 |
2000 | 3 | combined single limit | 18 |
2000 | 3 | combined single limit | 21 |
2000 | 3 | combined single limit | 24 |
2000 | 3 | combined single limit | 27 |
2000 | 3 | combined single limit | 30 |
2000 | 3 | combined single limit | 33 |
2000 | 3 | combined single limit | 36 |
2000 | 4 | combined single limit | 3 |
2000 | 4 | combined single limit | 6 |
2000 | 4 | combined single limit | 9 |
2000 | 4 | combined single limit | 12 |
2000 | 4 | combined single limit | 15 |
2000 | 4 | combined single limit | 18 |
2000 | 4 | combined single limit | 21 |
2000 | 4 | combined single limit | 24 |
2000 | 4 | combined single limit | 27 |
2000 | 4 | combined single limit | 30 |
2000 | 4 | combined single limit | 33 |
2000 | 4 | combined single limit | 36 |
2001 | 1 | combined single limit | 3 |
2001 | 1 | combined single limit | 6 |
2001 | 1 | combined single limit | 9 |
2001 | 1 | combined single limit | 12 |
2001 | 1 | combined single limit | 15 |
2001 | 1 | combined single limit | 18 |
2001 | 1 | combined single limit | 21 |
2001 | 1 | combined single limit | 24 |
2001 | 1 | combined single limit | 27 |
2001 | 1 | combined single limit | 30 |
2001 | 1 | combined single limit | 33 |
2001 | 1 | combined single limit | 36 |
2001 | 2 | combined single limit | 3 |
2001 | 2 | combined single limit | 6 |
2001 | 2 | combined single limit | 9 |
2001 | 2 | combined single limit | 12 |
2001 | 2 | combined single limit | 15 |
2001 | 2 | combined single limit | 18 |
2001 | 2 | combined single limit | 21 |
2001 | 2 | combined single limit | 24 |
2001 | 2 | combined single limit | 27 |
2001 | 2 | combined single limit | 30 |
2001 | 2 | combined single limit | 33 |
2001 | 2 | combined single limit | 36 |
2001 | 3 | combined single limit | 3 |
2001 | 3 | combined single limit | 6 |
2001 | 3 | combined single limit | 9 |
2001 | 3 | combined single limit | 12 |
2001 | 3 | combined single limit | 15 |
2001 | 3 | combined single limit | 18 |
2001 | 3 | combined single limit | 21 |
2001 | 3 | combined single limit | 24 |
2001 | 3 | combined single limit | 27 |
2001 | 3 | combined single limit | 30 |
2001 | 3 | combined single limit | 33 |
2001 | 3 | combined single limit | 36 |
2001 | 4 | combined single limit | 3 |
2001 | 4 | combined single limit | 6 |
2001 | 4 | combined single limit | 9 |
2001 | 4 | combined single limit | 12 |
2001 | 4 | combined single limit | 15 |
2001 | 4 | combined single limit | 18 |
2001 | 4 | combined single limit | 21 |
2001 | 4 | combined single limit | 24 |
2001 | 4 | combined single limit | 27 |
2001 | 4 | combined single limit | 30 |
2001 | 4 | combined single limit | 33 |
2001 | 4 | combined single limit | 36 |
2002 | 1 | combined single limit | 3 |
2002 | 1 | combined single limit | 6 |
2002 | 1 | combined single limit | 9 |
2002 | 1 | combined single limit | 12 |
2002 | 1 | combined single limit | 15 |
2002 | 1 | combined single limit | 18 |
2002 | 1 | combined single limit | 21 |
2002 | 1 | combined single limit | 24 |
2002 | 1 | combined single limit | 27 |
2002 | 1 | combined single limit | 30 |
2002 | 1 | combined single limit | 33 |
2002 | 1 | combined single limit | 36 |
2002 | 2 | combined single limit | 3 |
2002 | 2 | combined single limit | 6 |
2002 | 2 | combined single limit | 9 |
2002 | 2 | combined single limit | 12 |
2002 | 2 | combined single limit | 15 |
2002 | 2 | combined single limit | 18 |
2002 | 2 | combined single limit | 21 |
2002 | 2 | combined single limit | 24 |
2002 | 2 | combined single limit | 27 |
2002 | 2 | combined single limit | 30 |
2002 | 2 | combined single limit | 33 |
2002 | 2 | combined single limit | 36 |
2002 | 3 | combined single limit | 3 |
2002 | 3 | combined single limit | 6 |
2002 | 3 | combined single limit | 9 |
2002 | 3 | combined single limit | 12 |
2002 | 3 | combined single limit | 15 |
2002 | 3 | combined single limit | 18 |
2002 | 3 | combined single limit | 21 |
2002 | 3 | combined single limit | 24 |
2002 | 3 | combined single limit | 27 |
2002 | 3 | combined single limit | 30 |
2002 | 3 | combined single limit | 33 |
2002 | 3 | combined single limit | 36 |
2002 | 4 | combined single limit | 3 |
2002 | 4 | combined single limit | 6 |
2002 | 4 | combined single limit | 9 |
2002 | 4 | combined single limit | 12 |
2002 | 4 | combined single limit | 15 |
2002 | 4 | combined single limit | 18 |
2002 | 4 | combined single limit | 21 |
2002 | 4 | combined single limit | 24 |
2002 | 4 | combined single limit | 27 |
2002 | 4 | combined single limit | 30 |
2002 | 4 | combined single limit | 33 |
2002 | 4 | combined single limit | 36 |
2000 | 1 | uninsured motorist | 3 |
2000 | 1 | uninsured motorist | 6 |
2000 | 1 | uninsured motorist | 9 |
2000 | 1 | uninsured motorist | 12 |
2000 | 1 | uninsured motorist | 15 |
2000 | 1 | uninsured motorist | 18 |
2000 | 1 | uninsured motorist | 21 |
2000 | 1 | uninsured motorist | 24 |
2000 | 1 | uninsured motorist | 27 |
2000 | 1 | uninsured motorist | 30 |
2000 | 1 | uninsured motorist | 33 |
2000 | 1 | uninsured motorist | 36 |
2000 | 2 | uninsured motorist | 3 |
2000 | 2 | uninsured motorist | 6 |
2000 | 2 | uninsured motorist | 9 |
2000 | 2 | uninsured motorist | 12 |
2000 | 2 | uninsured motorist | 15 |
2000 | 2 | uninsured motorist | 18 |
2000 | 2 | uninsured motorist | 21 |
2000 | 2 | uninsured motorist | 24 |
2000 | 2 | uninsured motorist | 27 |
2000 | 2 | uninsured motorist | 30 |
2000 | 2 | uninsured motorist | 33 |
2000 | 2 | uninsured motorist | 36 |
2000 | 3 | uninsured motorist | 3 |
2000 | 3 | uninsured motorist | 6 |
2000 | 3 | uninsured motorist | 9 |
2000 | 3 | uninsured motorist | 12 |
2000 | 3 | uninsured motorist | 15 |
2000 | 3 | uninsured motorist | 18 |
2000 | 3 | uninsured motorist | 21 |
2000 | 3 | uninsured motorist | 24 |
2000 | 3 | uninsured motorist | 27 |
2000 | 3 | uninsured motorist | 30 |
2000 | 3 | uninsured motorist | 33 |
2000 | 3 | uninsured motorist | 36 |
2000 | 4 | uninsured motorist | 3 |
2000 | 4 | uninsured motorist | 6 |
2000 | 4 | uninsured motorist | 9 |
2000 | 4 | uninsured motorist | 12 |
2000 | 4 | uninsured motorist | 15 |
2000 | 4 | uninsured motorist | 18 |
2000 | 4 | uninsured motorist | 21 |
2000 | 4 | uninsured motorist | 24 |
2000 | 4 | uninsured motorist | 27 |
2000 | 4 | uninsured motorist | 30 |
2000 | 4 | uninsured motorist | 33 |
2000 | 4 | uninsured motorist | 36 |
2001 | 1 | uninsured motorist | 3 |
2001 | 1 | uninsured motorist | 6 |
2001 | 1 | uninsured motorist | 9 |
2001 | 1 | uninsured motorist | 12 |
2001 | 1 | uninsured motorist | 15 |
2001 | 1 | uninsured motorist | 18 |
2001 | 1 | uninsured motorist | 21 |
2001 | 1 | uninsured motorist | 24 |
2001 | 1 | uninsured motorist | 27 |
2001 | 1 | uninsured motorist | 30 |
2001 | 1 | uninsured motorist | 33 |
2001 | 1 | uninsured motorist | 36 |
2001 | 2 | uninsured motorist | 3 |
2001 | 2 | uninsured motorist | 6 |
2001 | 2 | uninsured motorist | 9 |
2001 | 2 | uninsured motorist | 12 |
2001 | 2 | uninsured motorist | 15 |
2001 | 2 | uninsured motorist | 18 |
2001 | 2 | uninsured motorist | 21 |
2001 | 2 | uninsured motorist | 24 |
2001 | 2 | uninsured motorist | 27 |
2001 | 2 | uninsured motorist | 30 |
2001 | 2 | uninsured motorist | 33 |
2001 | 2 | uninsured motorist | 36 |
2001 | 3 | uninsured motorist | 3 |
2001 | 3 | uninsured motorist | 6 |
2001 | 3 | uninsured motorist | 9 |
2001 | 3 | uninsured motorist | 12 |
2001 | 3 | uninsured motorist | 15 |
2001 | 3 | uninsured motorist | 18 |
2001 | 3 | uninsured motorist | 21 |
2001 | 3 | uninsured motorist | 24 |
2001 | 3 | uninsured motorist | 27 |
2001 | 3 | uninsured motorist | 30 |
2001 | 3 | uninsured motorist | 33 |
2001 | 3 | uninsured motorist | 36 |
2001 | 4 | uninsured motorist | 3 |
2001 | 4 | uninsured motorist | 6 |
2001 | 4 | uninsured motorist | 9 |
2001 | 4 | uninsured motorist | 12 |
2001 | 4 | uninsured motorist | 15 |
2001 | 4 | uninsured motorist | 18 |
2001 | 4 | uninsured motorist | 21 |
2001 | 4 | uninsured motorist | 24 |
2001 | 4 | uninsured motorist | 27 |
2001 | 4 | uninsured motorist | 30 |
2001 | 4 | uninsured motorist | 33 |
2001 | 4 | uninsured motorist | 36 |
2002 | 1 | uninsured motorist | 3 |
2002 | 1 | uninsured motorist | 6 |
2002 | 1 | uninsured motorist | 9 |
2002 | 1 | uninsured motorist | 12 |
2002 | 1 | uninsured motorist | 15 |
2002 | 1 | uninsured motorist | 18 |
2002 | 1 | uninsured motorist | 21 |
2002 | 1 | uninsured motorist | 24 |
2002 | 1 | uninsured motorist | 27 |
2002 | 1 | uninsured motorist | 30 |
2002 | 1 | uninsured motorist | 33 |
2002 | 1 | uninsured motorist | 36 |
2002 | 2 | uninsured motorist | 3 |
2002 | 2 | uninsured motorist | 6 |
2002 | 2 | uninsured motorist | 9 |
2002 | 2 | uninsured motorist | 12 |
2002 | 2 | uninsured motorist | 15 |
2002 | 2 | uninsured motorist | 18 |
2002 | 2 | uninsured motorist | 21 |
2002 | 2 | uninsured motorist | 24 |
2002 | 2 | uninsured motorist | 27 |
2002 | 2 | uninsured motorist | 30 |
2002 | 2 | uninsured motorist | 33 |
2002 | 2 | uninsured motorist | 36 |
2002 | 3 | uninsured motorist | 3 |
2002 | 3 | uninsured motorist | 6 |
2002 | 3 | uninsured motorist | 9 |
2002 | 3 | uninsured motorist | 12 |
2002 | 3 | uninsured motorist | 15 |
2002 | 3 | uninsured motorist | 18 |
2002 | 3 | uninsured motorist | 21 |
2002 | 3 | uninsured motorist | 24 |
2002 | 3 | uninsured motorist | 27 |
2002 | 3 | uninsured motorist | 30 |
2002 | 3 | uninsured motorist | 33 |
2002 | 3 | uninsured motorist | 36 |
2002 | 4 | uninsured motorist | 3 |
2002 | 4 | uninsured motorist | 6 |
2002 | 4 | uninsured motorist | 9 |
2002 | 4 | uninsured motorist | 12 |
2002 | 4 | uninsured motorist | 15 |
2002 | 4 | uninsured motorist | 18 |
2002 | 4 | uninsured motorist | 21 |
2002 | 4 | uninsured motorist | 24 |
2002 | 4 | uninsured motorist | 27 |
2002 | 4 | uninsured motorist | 30 |
2002 | 4 | uninsured motorist | 33 |
2002 | 4 | uninsured motorist | 36 |
BUT When I RUN the SAME PROGRAM ON 2003Q2 My table should look as shown below: (2000Q1 to 2003Q2=42 months,14 Quarters, 3 years)
year | quarter | Primary_coverage | months |
2000 | 1 | combined single limit | 3 |
2000 | 1 | combined single limit | 6 |
2000 | 1 | combined single limit | 9 |
2000 | 1 | combined single limit | 12 |
2000 | 1 | combined single limit | 15 |
2000 | 1 | combined single limit | 18 |
2000 | 1 | combined single limit | 21 |
2000 | 1 | combined single limit | 24 |
2000 | 1 | combined single limit | 27 |
2000 | 1 | combined single limit | 30 |
2000 | 1 | combined single limit | 33 |
2000 | 1 | combined single limit | 36 |
2000 | 1 | combined single limit | 39 |
2000 | 1 | combined single limit | 42 |
2000 | 2 | combined single limit | 3 |
2000 | 2 | combined single limit | 6 |
2000 | 2 | combined single limit | 9 |
2000 | 2 | combined single limit | 12 |
2000 | 2 | combined single limit | 15 |
2000 | 2 | combined single limit | 18 |
2000 | 2 | combined single limit | 21 |
2000 | 2 | combined single limit | 24 |
2000 | 2 | combined single limit | 27 |
2000 | 2 | combined single limit | 30 |
2000 | 2 | combined single limit | 33 |
2000 | 2 | combined single limit | 36 |
2000 | 2 | combined single limit | 39 |
2000 | 2 | combined single limit | 42 |
2000 | 3 | combined single limit | 3 |
2000 | 3 | combined single limit | 6 |
2000 | 3 | combined single limit | 9 |
2000 | 3 | combined single limit | 12 |
2000 | 3 | combined single limit | 15 |
2000 | 3 | combined single limit | 18 |
2000 | 3 | combined single limit | 21 |
2000 | 3 | combined single limit | 24 |
2000 | 3 | combined single limit | 27 |
2000 | 3 | combined single limit | 30 |
2000 | 3 | combined single limit | 33 |
2000 | 3 | combined single limit | 36 |
2000 | 3 | combined single limit | 39 |
2000 | 3 | combined single limit | 42 |
2000 | 4 | combined single limit | 3 |
2000 | 4 | combined single limit | 6 |
2000 | 4 | combined single limit | 9 |
2000 | 4 | combined single limit | 12 |
2000 | 4 | combined single limit | 15 |
2000 | 4 | combined single limit | 18 |
2000 | 4 | combined single limit | 21 |
2000 | 4 | combined single limit | 24 |
2000 | 4 | combined single limit | 27 |
2000 | 4 | combined single limit | 30 |
2000 | 4 | combined single limit | 33 |
2000 | 4 | combined single limit | 36 |
2000 | 4 | combined single limit | 39 |
2000 | 4 | combined single limit | 42 |
2001 | 1 | combined single limit | 3 |
2001 | 1 | combined single limit | 6 |
2001 | 1 | combined single limit | 9 |
2001 | 1 | combined single limit | 12 |
2001 | 1 | combined single limit | 15 |
2001 | 1 | combined single limit | 18 |
2001 | 1 | combined single limit | 21 |
2001 | 1 | combined single limit | 24 |
2001 | 1 | combined single limit | 27 |
2001 | 1 | combined single limit | 30 |
2001 | 1 | combined single limit | 33 |
2001 | 1 | combined single limit | 36 |
2001 | 1 | combined single limit | 39 |
2001 | 1 | combined single limit | 42 |
2001 | 2 | combined single limit | 3 |
2001 | 2 | combined single limit | 6 |
2001 | 2 | combined single limit | 9 |
2001 | 2 | combined single limit | 12 |
2001 | 2 | combined single limit | 15 |
2001 | 2 | combined single limit | 18 |
2001 | 2 | combined single limit | 21 |
2001 | 2 | combined single limit | 24 |
2001 | 2 | combined single limit | 27 |
2001 | 2 | combined single limit | 30 |
2001 | 2 | combined single limit | 33 |
2001 | 2 | combined single limit | 36 |
2001 | 2 | combined single limit | 39 |
2001 | 2 | combined single limit | 42 |
2001 | 3 | combined single limit | 3 |
2001 | 3 | combined single limit | 6 |
2001 | 3 | combined single limit | 9 |
2001 | 3 | combined single limit | 12 |
2001 | 3 | combined single limit | 15 |
2001 | 3 | combined single limit | 18 |
2001 | 3 | combined single limit | 21 |
2001 | 3 | combined single limit | 24 |
2001 | 3 | combined single limit | 27 |
2001 | 3 | combined single limit | 30 |
2001 | 3 | combined single limit | 33 |
2001 | 3 | combined single limit | 36 |
2001 | 3 | combined single limit | 39 |
2001 | 3 | combined single limit | 42 |
2001 | 4 | combined single limit | 3 |
2001 | 4 | combined single limit | 6 |
2001 | 4 | combined single limit | 9 |
2001 | 4 | combined single limit | 12 |
2001 | 4 | combined single limit | 15 |
2001 | 4 | combined single limit | 18 |
2001 | 4 | combined single limit | 21 |
2001 | 4 | combined single limit | 24 |
2001 | 4 | combined single limit | 27 |
2001 | 4 | combined single limit | 30 |
2001 | 4 | combined single limit | 33 |
2001 | 4 | combined single limit | 36 |
2001 | 4 | combined single limit | 39 |
2001 | 4 | combined single limit | 42 |
2002 | 1 | combined single limit | 3 |
2002 | 1 | combined single limit | 6 |
2002 | 1 | combined single limit | 9 |
2002 | 1 | combined single limit | 12 |
2002 | 1 | combined single limit | 15 |
2002 | 1 | combined single limit | 18 |
2002 | 1 | combined single limit | 21 |
2002 | 1 | combined single limit | 24 |
2002 | 1 | combined single limit | 27 |
2002 | 1 | combined single limit | 30 |
2002 | 1 | combined single limit | 33 |
2002 | 1 | combined single limit | 36 |
2002 | 1 | combined single limit | 39 |
2002 | 1 | combined single limit | 42 |
2002 | 2 | combined single limit | 3 |
2002 | 2 | combined single limit | 6 |
2002 | 2 | combined single limit | 9 |
2002 | 2 | combined single limit | 12 |
2002 | 2 | combined single limit | 15 |
2002 | 2 | combined single limit | 18 |
2002 | 2 | combined single limit | 21 |
2002 | 2 | combined single limit | 24 |
2002 | 2 | combined single limit | 27 |
2002 | 2 | combined single limit | 30 |
2002 | 2 | combined single limit | 33 |
2002 | 2 | combined single limit | 36 |
2002 | 2 | combined single limit | 39 |
2002 | 2 | combined single limit | 42 |
2002 | 3 | combined single limit | 3 |
2002 | 3 | combined single limit | 6 |
2002 | 3 | combined single limit | 9 |
2002 | 3 | combined single limit | 12 |
2002 | 3 | combined single limit | 15 |
2002 | 3 | combined single limit | 18 |
2002 | 3 | combined single limit | 21 |
2002 | 3 | combined single limit | 24 |
2002 | 3 | combined single limit | 27 |
2002 | 3 | combined single limit | 30 |
2002 | 3 | combined single limit | 33 |
2002 | 3 | combined single limit | 36 |
2002 | 3 | combined single limit | 39 |
2002 | 3 | combined single limit | 42 |
2002 | 4 | combined single limit | 3 |
2002 | 4 | combined single limit | 6 |
2002 | 4 | combined single limit | 9 |
2002 | 4 | combined single limit | 12 |
2002 | 4 | combined single limit | 15 |
2002 | 4 | combined single limit | 18 |
2002 | 4 | combined single limit | 21 |
2002 | 4 | combined single limit | 24 |
2002 | 4 | combined single limit | 27 |
2002 | 4 | combined single limit | 30 |
2002 | 4 | combined single limit | 33 |
2002 | 4 | combined single limit | 36 |
2002 | 4 | combined single limit | 39 |
2002 | 4 | combined single limit | 42 |
2003 | 1 | combined single limit | 3 |
2003 | 1 | combined single limit | 6 |
2003 | 1 | combined single limit | 9 |
2003 | 1 | combined single limit | 12 |
2003 | 1 | combined single limit | 15 |
2003 | 1 | combined single limit | 18 |
2003 | 1 | combined single limit | 21 |
2003 | 1 | combined single limit | 24 |
2003 | 1 | combined single limit | 27 |
2003 | 1 | combined single limit | 30 |
2003 | 1 | combined single limit | 33 |
2003 | 1 | combined single limit | 36 |
2003 | 1 | combined single limit | 39 |
2003 | 1 | combined single limit | 42 |
2003 | 2 | combined single limit | 3 |
2003 | 2 | combined single limit | 6 |
2003 | 2 | combined single limit | 9 |
2003 | 2 | combined single limit | 12 |
2003 | 2 | combined single limit | 15 |
2003 | 2 | combined single limit | 18 |
2003 | 2 | combined single limit | 21 |
2003 | 2 | combined single limit | 24 |
2003 | 2 | combined single limit | 27 |
2003 | 2 | combined single limit | 30 |
2003 | 2 | combined single limit | 33 |
2003 | 2 | combined single limit | 36 |
2003 | 2 | combined single limit | 39 |
2003 | 2 | combined single limit | 42 |
2000 | 1 | uninsured motorist | 3 |
2000 | 1 | uninsured motorist | 6 |
2000 | 1 | uninsured motorist | 9 |
2000 | 1 | uninsured motorist | 12 |
2000 | 1 | uninsured motorist | 15 |
2000 | 1 | uninsured motorist | 18 |
2000 | 1 | uninsured motorist | 21 |
2000 | 1 | uninsured motorist | 24 |
2000 | 1 | uninsured motorist | 27 |
2000 | 1 | uninsured motorist | 30 |
2000 | 1 | uninsured motorist | 33 |
2000 | 1 | uninsured motorist | 36 |
2000 | 1 | uninsured motorist | 39 |
2000 | 1 | uninsured motorist | 42 |
2000 | 2 | uninsured motorist | 3 |
2000 | 2 | uninsured motorist | 6 |
2000 | 2 | uninsured motorist | 9 |
2000 | 2 | uninsured motorist | 12 |
2000 | 2 | uninsured motorist | 15 |
2000 | 2 | uninsured motorist | 18 |
2000 | 2 | uninsured motorist | 21 |
2000 | 2 | uninsured motorist | 24 |
2000 | 2 | uninsured motorist | 27 |
2000 | 2 | uninsured motorist | 30 |
2000 | 2 | uninsured motorist | 33 |
2000 | 2 | uninsured motorist | 36 |
2000 | 2 | uninsured motorist | 39 |
2000 | 2 | uninsured motorist | 42 |
2000 | 3 | uninsured motorist | 3 |
2000 | 3 | uninsured motorist | 6 |
2000 | 3 | uninsured motorist | 9 |
2000 | 3 | uninsured motorist | 12 |
2000 | 3 | uninsured motorist | 15 |
2000 | 3 | uninsured motorist | 18 |
2000 | 3 | uninsured motorist | 21 |
2000 | 3 | uninsured motorist | 24 |
2000 | 3 | uninsured motorist | 27 |
2000 | 3 | uninsured motorist | 30 |
2000 | 3 | uninsured motorist | 33 |
2000 | 3 | uninsured motorist | 36 |
2000 | 3 | uninsured motorist | 39 |
2000 | 3 | uninsured motorist | 42 |
2000 | 4 | uninsured motorist | 3 |
2000 | 4 | uninsured motorist | 6 |
2000 | 4 | uninsured motorist | 9 |
2000 | 4 | uninsured motorist | 12 |
2000 | 4 | uninsured motorist | 15 |
2000 | 4 | uninsured motorist | 18 |
2000 | 4 | uninsured motorist | 21 |
2000 | 4 | uninsured motorist | 24 |
2000 | 4 | uninsured motorist | 27 |
2000 | 4 | uninsured motorist | 30 |
2000 | 4 | uninsured motorist | 33 |
2000 | 4 | uninsured motorist | 36 |
2000 | 4 | uninsured motorist | 39 |
2000 | 4 | uninsured motorist | 42 |
2001 | 1 | uninsured motorist | 3 |
2001 | 1 | uninsured motorist | 6 |
2001 | 1 | uninsured motorist | 9 |
2001 | 1 | uninsured motorist | 12 |
2001 | 1 | uninsured motorist | 15 |
2001 | 1 | uninsured motorist | 18 |
2001 | 1 | uninsured motorist | 21 |
2001 | 1 | uninsured motorist | 24 |
2001 | 1 | uninsured motorist | 27 |
2001 | 1 | uninsured motorist | 30 |
2001 | 1 | uninsured motorist | 33 |
2001 | 1 | uninsured motorist | 36 |
2001 | 1 | uninsured motorist | 39 |
2001 | 1 | uninsured motorist | 42 |
2001 | 2 | uninsured motorist | 3 |
2001 | 2 | uninsured motorist | 6 |
2001 | 2 | uninsured motorist | 9 |
2001 | 2 | uninsured motorist | 12 |
2001 | 2 | uninsured motorist | 15 |
2001 | 2 | uninsured motorist | 18 |
2001 | 2 | uninsured motorist | 21 |
2001 | 2 | uninsured motorist | 24 |
2001 | 2 | uninsured motorist | 27 |
2001 | 2 | uninsured motorist | 30 |
2001 | 2 | uninsured motorist | 33 |
2001 | 2 | uninsured motorist | 36 |
2001 | 2 | uninsured motorist | 39 |
2001 | 2 | uninsured motorist | 42 |
2001 | 3 | uninsured motorist | 3 |
2001 | 3 | uninsured motorist | 6 |
2001 | 3 | uninsured motorist | 9 |
2001 | 3 | uninsured motorist | 12 |
2001 | 3 | uninsured motorist | 15 |
2001 | 3 | uninsured motorist | 18 |
2001 | 3 | uninsured motorist | 21 |
2001 | 3 | uninsured motorist | 24 |
2001 | 3 | uninsured motorist | 27 |
2001 | 3 | uninsured motorist | 30 |
2001 | 3 | uninsured motorist | 33 |
2001 | 3 | uninsured motorist | 36 |
2001 | 3 | uninsured motorist | 39 |
2001 | 3 | uninsured motorist | 42 |
2001 | 4 | uninsured motorist | 3 |
2001 | 4 | uninsured motorist | 6 |
2001 | 4 | uninsured motorist | 9 |
2001 | 4 | uninsured motorist | 12 |
2001 | 4 | uninsured motorist | 15 |
2001 | 4 | uninsured motorist | 18 |
2001 | 4 | uninsured motorist | 21 |
2001 | 4 | uninsured motorist | 24 |
2001 | 4 | uninsured motorist | 27 |
2001 | 4 | uninsured motorist | 30 |
2001 | 4 | uninsured motorist | 33 |
2001 | 4 | uninsured motorist | 36 |
2001 | 4 | uninsured motorist | 39 |
2001 | 4 | uninsured motorist | 42 |
2002 | 1 | uninsured motorist | 3 |
2002 | 1 | uninsured motorist | 6 |
2002 | 1 | uninsured motorist | 9 |
2002 | 1 | uninsured motorist | 12 |
2002 | 1 | uninsured motorist | 15 |
2002 | 1 | uninsured motorist | 18 |
2002 | 1 | uninsured motorist | 21 |
2002 | 1 | uninsured motorist | 24 |
2002 | 1 | uninsured motorist | 27 |
2002 | 1 | uninsured motorist | 30 |
2002 | 1 | uninsured motorist | 33 |
2002 | 1 | uninsured motorist | 36 |
2002 | 1 | uninsured motorist | 39 |
2002 | 1 | uninsured motorist | 42 |
2002 | 2 | uninsured motorist | 3 |
2002 | 2 | uninsured motorist | 6 |
2002 | 2 | uninsured motorist | 9 |
2002 | 2 | uninsured motorist | 12 |
2002 | 2 | uninsured motorist | 15 |
2002 | 2 | uninsured motorist | 18 |
2002 | 2 | uninsured motorist | 21 |
2002 | 2 | uninsured motorist | 24 |
2002 | 2 | uninsured motorist | 27 |
2002 | 2 | uninsured motorist | 30 |
2002 | 2 | uninsured motorist | 33 |
2002 | 2 | uninsured motorist | 36 |
2002 | 2 | uninsured motorist | 39 |
2002 | 2 | uninsured motorist | 42 |
2002 | 3 | uninsured motorist | 3 |
2002 | 3 | uninsured motorist | 6 |
2002 | 3 | uninsured motorist | 9 |
2002 | 3 | uninsured motorist | 12 |
2002 | 3 | uninsured motorist | 15 |
2002 | 3 | uninsured motorist | 18 |
2002 | 3 | uninsured motorist | 21 |
2002 | 3 | uninsured motorist | 24 |
2002 | 3 | uninsured motorist | 27 |
2002 | 3 | uninsured motorist | 30 |
2002 | 3 | uninsured motorist | 33 |
2002 | 3 | uninsured motorist | 36 |
2002 | 3 | uninsured motorist | 39 |
2002 | 3 | uninsured motorist | 42 |
2002 | 4 | uninsured motorist | 3 |
2002 | 4 | uninsured motorist | 6 |
2002 | 4 | uninsured motorist | 9 |
2002 | 4 | uninsured motorist | 12 |
2002 | 4 | uninsured motorist | 15 |
2002 | 4 | uninsured motorist | 18 |
2002 | 4 | uninsured motorist | 21 |
2002 | 4 | uninsured motorist | 24 |
2002 | 4 | uninsured motorist | 27 |
2002 | 4 | uninsured motorist | 30 |
2002 | 4 | uninsured motorist | 33 |
2002 | 4 | uninsured motorist | 36 |
2002 | 4 | uninsured motorist | 39 |
2002 | 4 | uninsured motorist | 42 |
2003 | 1 | uninsured motorist | 3 |
2003 | 1 | uninsured motorist | 6 |
2003 | 1 | uninsured motorist | 9 |
2003 | 1 | uninsured motorist | 12 |
2003 | 1 | uninsured motorist | 15 |
2003 | 1 | uninsured motorist | 18 |
2003 | 1 | uninsured motorist | 21 |
2003 | 1 | uninsured motorist | 24 |
2003 | 1 | uninsured motorist | 27 |
2003 | 1 | uninsured motorist | 30 |
2003 | 1 | uninsured motorist | 33 |
2003 | 1 | uninsured motorist | 36 |
2003 | 1 | uninsured motorist | 39 |
2003 | 1 | uninsured motorist | 42 |
2003 | 2 | uninsured motorist | 3 |
2003 | 2 | uninsured motorist | 6 |
2003 | 2 | uninsured motorist | 9 |
2003 | 2 | uninsured motorist | 12 |
2003 | 2 | uninsured motorist | 15 |
2003 | 2 | uninsured motorist | 18 |
2003 | 2 | uninsured motorist | 21 |
2003 | 2 | uninsured motorist | 24 |
2003 | 2 | uninsured motorist | 27 |
2003 | 2 | uninsured motorist | 30 |
2003 | 2 | uninsured motorist | 33 |
2003 | 2 | uninsured motorist | 36 |
2003 | 2 | uninsured motorist | 39 |
2003 | 2 | uninsured motorist | 42 |
This can be done without a macro:
data coverage;
primary_coverage="combined single limit";
output;
primary_coverage="uninsured motorist";
output;
run;
data want;
length year quarter 8;
set coverage;
do year=2000 to 2002;
do quarter=1 to 4;
do months=3 to 36 by 3;
output;
end;
end;
end;
run;
You posted this in several places yesterday and received several solutions. Please don't repost the same question.
Did neither of the proposed solutions work for you?
Create a list of coverage types:
proc sql noprint;
Select distinct quote(primary_coverage) into :cov_list separated by ' ,'
From coverage_list;
Quit;
Then you can modify the do loop in the code above, either mine or Astoundings.
Do coverage = &cov_list;
Here's a full data step solution, that only requires the end date, assuming you always end at 2000.
Replace your categories in the coverage list.
%let end_date = 2003Q2;
data date_list;
format end_date date9. coverage $20.;
end_date=input("&end_date", yyq6.);
n_months=intck('month', '01Jan2000'd, end_date)+3;
do coverage='Primary', 'Secondary', 'Tertiary';
date=end_date;
do months=n_months to 3 by -3;
year=year(date);
quarter=qtr(date);
date=intnx('month', date, -3, 'b');
output;
end;
end;
Keep year quarter months coverage;
run;
Don't miss out on SAS Innovate - Register now for the FREE Livestream!
Can't make it to Vegas? No problem! Watch our general sessions LIVE or on-demand starting April 17th. Hear from SAS execs, best-selling author Adam Grant, Hot Ones host Sean Evans, top tech journalist Kara Swisher, AI expert Cassie Kozyrkov, and the mind-blowing dance crew iLuminate! Plus, get access to over 20 breakout sessions.
Learn how use the CAT functions in SAS to join values from multiple variables into a single value.
Find more tutorials on the SAS Users YouTube channel.