I assume:
1) your data have more then one day.
2) the data is already sorted by datepart timepart and
time_cat is assigned correctly according to timepart/
In such case I preffer to create all time_cat(s) entries and merge them with the given data as in next tested code. Do you realy need the sensor on the new added rows?
It can be done within the merge step or in a new step by using similar methods as in my previous post.
The code is:
%let dt_start = '18JUL2019'd; /*** adapt dt_start dt_end dates as need ***/
%let dt_end = '18JUL2019'd;
data cats;
format datepart DDMMYY. timepart TIME.;
do datepart = &dt_start to &dt_end by 1;
timepart = 0; time_cat=0; output;
timepart = input('06:00't,hhmm5.); time_cat=0; output;
timepart = input('06:00't,hhmm5.); time_cat=1; output;
timepart = input('10:00't,hhmm5.); time_cat=1; output;
timepart = input('11:00't,hhmm5.); time_cat=2; output;
timepart = input('15:00't,hhmm5.); time_cat=2; output;
timepart = input('17:00't,hhmm5.); time_cat=3; output;
timepart = input('21:00't,hhmm5.); time_cat=3; output;
end;
run;
data temp;
merge measure_tp cats;
by datepart timepart;
run;
... View more