I first created the dataset as follows: data subdata;
set storage.data1;
date1 = input(a_dt, yymmdd10.);
date2=input(b_dt,yymmdd10.);
format date1 date2 yymmn6.;
if date1 ge "01Jan2018"d;
run; The dataset is set up so there's a bunch of columns m01...m36 such that each column has information about a status for that given month. Each number of the month are x months after month 0. Month 0 is the month in "lastdate" below: data testing;
set subdata;
%let lastdate = %sysfunc(inputn(202012,yymmn6.));
%let monthdiff=%sysfunc(INTCK(MONTH,date1,&lastdate));
%let t0=m&monthdiff.;
%let t1=m%eval(&monthdiff-1).;
%let t2=m%eval(&monthdiff-2).;
%let t3=m%eval(&monthdiff-3).;
%let t4=m%eval(&monthdiff-4).;
%let t5=m%eval(&monthdiff-5).;
%let t6=m%eval(&monthdiff-6).;
...
...
Check conditions for each t, etc.
For example, if "date1" is 7 months away from the "lastdate" variable, then monthdiff will equal 7, t0=m7,t1=m6, so on and so forth. Then I will check if each tx variable (which references an mx column) has a certain value and if it does, an indicator variable will generate a 1. When I try to run the %let monthdiff=%sysfunc(INTCK(MONTH,date1,&lastdate)) line, I get the ERROR: Argument 2 to function INTCK referenced by the %SYSFUNC or %QSYSFUNC macro function is not a number and then ERROR: Invalid arguments detected in %SYSCALL, %SYSFUNC, or %QSYSFUNC argument list. Execution of %SYSCALL statement or %SYSFUNC or %QSYSFUNC function reference is terminated. Date1 is the column with dates that will dynamically change the monthdiff variable, and thus each "t" variable. How can I pass that date column into the INTCK function? I'm very new to sas. I also realize I can easily change the "%let t1, let t2, etc." lines into a macro but I ran into other issues with that.
... View more