Hello All,
I am trying to fix someones code which fails due to hard-coding with the date ranges.
call symput ('count_range', 'count&file_dt1.-count20200501
count20200430-count20200402');
call symput ('balance_range', 'chd_current_balance_&file_dt1.-chd_current_balance_20200501
chd_current_balance_20200430-chd_current_balance_20200402');
Output :
count20200520-count20200501
count20200430-count20200402
chd_current_balance_20200520-chd_current_balance_20200501
chd_current_balance_20200430-chd_current_balance_20200402
The failure is caused whenever there is a sparsity of the data in the repository in this case the data for 20200519 was missing, which is uncommon but happens sometimes. (To give a little credit to the original developer , this code was meant to be run only for few days and he/she took a short cut ).
One approach that might work is a Proc SQL Code which lists all the available dates (I am yet to test this )
proc sql noprint;
select distinct cats('count',put(enrollment_dt,yymmddn.)) ,
cats('chd_current_balance_',put(enrollment_dt,yymmddn.))
into : count_range separated by ' ',:balance_range separated by ' '
from in.repository_current
where ^ missing(enrollment_dt);
quit;
I am wondering if there is a way to replicate the date ranges similar to the original formats used in the code :
chd_current_balance_20200501-chd_current_balance_20200518 chd_current_balance_20200520
count20200501-count20200518 count20200520
Creating a range till the data is continuously available and either list the subsequent values after the break or create a new range.
here is what i have tried so far :
The enrollment_dt has dates from 20200402 to till date with few dates missing in between
Proc freq data=in.repository_current;
tables enrollment_dt / missing out= temp1(keep=enrollment_dt);
where ^ missing(enrollment_dt);
format enrollment_dt yymmddn.;
run;
data temp2;
set temp1;
mon=month(enrollment_dt);
run;
data temp3;
do _n_=1 by 1 until(last.mon);
array dt[999] _temporary_;
set temp2;
by mon;
dt[_n_]=enrollment_dt;
end;
run;
Any help is appreciated.
... View more