Also attached are the following:
* Output showing my data before and after running proc expand on the data is the piece of code that
Typically PROC TIMESERIES is used to fill gaps.
https://gist.github.com/statgeek/07a3708dee1225ceb9d4aa75daab2c52
Thanks Reeza. Your reply gave me a clue.
The answer is to use proc expand with the option method=step to get the previously missing observation to use field values for the last non-missing observation.
Bravo @Bobbe_Stiff! Please post your solution code (using the {i} button) to help future users facing the same problem. You can mark your own solution as the correct answer too.
Here is the code to use PROC TIMEDATA to fill the time ID gaps using the previous values.
data test;
length claim $3 claims_lodgement_date date_of_injury snapshot_date dev_month_lodge dev_month_injury netcostc netpayc 8;
format claims_lodgement_date date_of_injury snapshot_date date9. netcostc netpayc dollar10. ;
format dev_month_lodge dev_month_injury 3.;
informat claims_lodgement_date date_of_injury snapshot_date date9.;
infile datalines delimiter=',' dsd;
input claim claims_lodgement_date date_of_injury snapshot_date dev_month_lodge dev_month_injury netcostc netpayc ;
put _all_;
datalines;
XYZ,01FEB1994,21JUL1993,28FEB1994,0,7,80,80
XYZ,01FEB1994,21JUL1993,30APR1994,2,9,3961,3961
;
run;
proc timedata data=test out=step11;
by claim;
var claims_lodgement_date date_of_injury Dev_Month_Lodge Dev_Month_Injury netcostc netpayc;
id snapshot_date interval = month setmissing = prev;
run;
Don’t miss the livestream kicking off May 7. It’s free. It’s easy. And it’s the best seat in the house.
Join us virtually with our complimentary SAS Innovate Digital Pass. Watch live or on-demand in multiple languages, with translations available to help you get the most out of every session.