Hi All, I'm trying to do the below steps to complete one of the requirements. 1. Take the first observation weight value and assign it to a macro variable. 2.From the next row compare the weight with macro variable and check if the change in weight is more than 10% . 3. If the change in weight is greater than 10% then update the macro variable with the current row weight value. 4. Continue the above steps. I've used the below code but Step 3 in the above seems to be failing. Could you please advise on the steps to achieve this or any other alternate solutions? %macro process;
data a;
set outdata.dummy_weights(firstobs = 1 obs = 1);
%global ref;
call symput('ref', weight_digit);
run;
data dosing4;
set outdata.dummy_weights;
if cycle eq "Cycles 1" then weight_baseline = weight_digit;
if cycle ne "Cycles 1" then
if (((weight_digit - %sysevalf(&ref)) / (%sysevalf(&ref))) * 100) > 10 then
do;
weight_baseline = weight_digit;
call symput('ref', weight_baseline);
%put &ref;
end;
else
weight_baseline = symget('ref');
run;
/*%put &ref;*/
%mend;
%process;
Sample Data set: SR. No. Cycle Weight Weight_digit 1 Cycles 1 80KG 80 2 Cycle 2 80KG 80 3 Cycle2.1 80KG 80 4 Cycle2.2 80KG 80 5 Cycle 3 89KG 89 6 Cycle 4 89KG 89 7 Cycle 5 92KG 92 8 Cycle 6 95KG 95 9 Cycle 7 99KG 99
... View more