Hi I want to use WOCF for my dataset but How can you do that. so I have two dataset code which one i have and what i want. please help me I tried Lag but didn't succeed.
data have;
input id $ visitnum aval ;
datalines;
1 1 0
1 2 3
1 3 3
1 4 4
1 5 3
1 6 3
1 7 3
1 8 4
1 9 4
;
run;
data want;
input id $ visitnum aval dtype ;
datalines;
1 1 0
1 2 3
1 3 3
1 4 4
1 5 4 WOCF
1 6 4 WOCF
1 7 4 WOCF
1 8 4
1 9 4
;
run;
retain _aval;
if first.id then _aval = aval;
if aval lt _aval
then do;
aval = _aval;
dtype = 'WOCF';
end;
else _aval = aval;
drop _aval;
with Lag function I only manqged to change next one but i don't know how to do that with other two .
retain _aval;
if first.id then _aval = aval;
if aval lt _aval
then do;
aval = _aval;
dtype = 'WOCF';
end;
else _aval = aval;
drop _aval;
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.