Hello SAS Experts, Possibly a very simple solution to my problem but please advise. I cannot get the Prior_Check variable to evaluate with the proper value. Any help would be appreciated. Data Sample;
input Date_order Time_order Curr_Value Level1 Level2;
datalines;
0 1 100 125 110
0 2 103.5 124 109
;
run;
Data Sample_Evaluation;
set Sample;
Length Live_Check Prior_Check Decision $35.;
Live_Check='0000';
Prior_Check='0000';
Decision='0000';
run;
Data Sample_Evaluation;
/*retain Decision;*//* this statement did not work for me*/
set Sample_Evaluation;
/*by Date_order Time_order Decision;*/ /* this statement did not work for me*/
if Date_order=0 and Time_order=1 then do;
if Curr_Value> Level1 then do;
Live_Check='Active';
Decision='Active - High';
end;
if Curr_Value< Level2 then do;
Live_Check='Active';
Decision='Active-Low';
end;
end;
if Date_order=0 and Time_order=2 then do;
if Curr_Value> Level1 then do;
Live_Check='Active';
Prior_Check=lag(Decision);
if Live_Check='Active' and Prior_Check='0000' then do;
Decision='Active - High';
end;
else if Live_Check='Active' and Prior_Check ne '0000' then do;
Decision='Already Active - High';
end;
end;
if Curr_Value< Level2 then do;
Live_Check='Active';
Prior_Check=lag(Decision);/*want this to evaluate to 'Active - Low'*/
if Live_Check='Active' and Prior_Check='0000' then do;
Decision='Active - Low';
end;
else if Live_Check='Active' and Prior_Check ne '0000' then do;
Decision='Already Active - Low';
end;
end;
end;
run;
... View more