I'm trying to run a macro that looks at data at different time periods. Currently I have it looking at time periods on a continuous loop, i.e. from 1 month to 12 months. I want to be able to look at a set of specific time periods instead of a continuous list.
For example, I'd like to look at time periods 1,3,6,9,12,18,24 instead of having to run it from 1 to 24.
I'll post my code below and point out where I need it to be changed.
I know that I can do this outside of the macro language, but for the purposes of naming my data sets and identifying them later on for more analysis I believe I have to do this in a macro setting. Any help at all would be appreciated.
%macro dosql;
%do j = 0 %to 11;
%do i = 1 %to 24;
proc sql;
create table time_&j. as
select
case_nbr,
sqnc_nbr,
dflt_sts_cd,
ft_in_eps_3mnth_delq_dt,
dflt_cyc_dt
from sf.sfdw_default_history
where ft_in_eps_3mnth_delq_dt <= intnx('month',"15&m.&yr."d,&j.,'end')
and ft_in_eps_3mnth_delq_dt >= intnx('month',"15&m.&yr."d,&j., 'beginning')
order by case_nbr, sqnc_nbr;
quit;
data time_&j.;
set time_&j.;
format status $12. time.2;
status = '.';
time = '.';
run; quit;
proc sql;
create table time_&j._&i. as
select *
from time_&j.
where dflt_cyc_dt <= intnx('month',ft_in_eps_3mnth_delq_dt,&i., 'end')
order by case_nbr, sqnc_nbr;
quit;
data time_&j._&i.;
set time_&j._&i.;
by case_nbr;
if (last.case_nbr = 0) then delete;
run; quit;
data time_&j._&i.;
set time_&j._&i.;
time = "&i.";
eval_time = intnx('month',ft_in_eps_3mnth_delq_dt,&i., 'end');
format eval_time date9.;
run; quit;
data time_&j._&i.;
set time_&j._&i.;
by eval_time;
if eval_time > "&cutoff."d then delete;
run; quit;
data master_data;
set time_0 time_&j._&i.;
run; quit;
%end;
%end;
%mend;
options mprint;
%dosql;
So where it has i = 1 %to 24
I want to run it over a discrete list of numbers rather than all 24
Thanks again,
Kris G