Hi @Beto16,
Would this work for you?
data have;
input Machine $ Date :mmddyy. Load Use;
format Date mmddyy8.;
cards;
A1 02/03/16 160 31
A1 02/18/16 40 83
A1 02/25/17 80 0
A2 02/03/16 150 80
A2 02/18/16 70 70
A2 02/25/17 42 43
;
data want;
set have;
by machine date;
if first.machine then load1=load;
else if use>load>. then load=load1;
retain load1;
drop load1;
run;
This code doesn't use a DO statement, but unlike your suggested code it involves a condition with "greater than."
It's good that you posted an example, but it would be even better if, in addition, you stated the rule ("if ... greater than ..., then ...") in general terms (e.g. "... then use the load value of the first observation of the machine" or "... then use the load value from the previous observation of the same machine" ...).
Edit: Modified the test data for machine A2 a bit to make it more significant.
Available on demand!
Missed SAS Innovate Las Vegas? Watch all the action for free! View the keynotes, general sessions and 22 breakouts on demand.
Learn how use the CAT functions in SAS to join values from multiple variables into a single value.
Find more tutorials on the SAS Users YouTube channel.