i want to assign values for EXD based on the below condition
EXT is "pine", EXD should be assigned by value 2 for the first 2 days, value 4 for the next 2 days and value 6 for the remaining Period A. If EXT is "ozi", EXD should be assigned by value 5 for the first 2 days, value 10 for the next 2 days and value 15 for the remaining Period A.
Attached test data. can any one suggest how to do it.?
Hi @vraj1,
There are at least two possible interpretations of your criteria and hence different solutions:
data want;
set test(drop=exd);
if period='A' then do;
if ext='pine' then exd=2*min(int((day+1)/2),3);
else if ext='ozi' then exd=5*min(int((day+1)/2),3);
end;
run;
data want;
set test(drop=exd);
by id day;
if first.id then call missing(_cp, _co);
if period='A' then do;
if ext='pine' then do; _cp+1; exd=2*min(int((_cp+1)/2),3); end;
else if ext='ozi' then do; _co+1; exd=5*min(int((_co+1)/2),3); end;
end;
drop _:;
run;
Hi @vraj1,
There are at least two possible interpretations of your criteria and hence different solutions:
data want;
set test(drop=exd);
if period='A' then do;
if ext='pine' then exd=2*min(int((day+1)/2),3);
else if ext='ozi' then exd=5*min(int((day+1)/2),3);
end;
run;
data want;
set test(drop=exd);
by id day;
if first.id then call missing(_cp, _co);
if period='A' then do;
if ext='pine' then do; _cp+1; exd=2*min(int((_cp+1)/2),3); end;
else if ext='ozi' then do; _co+1; exd=5*min(int((_co+1)/2),3); end;
end;
drop _:;
run;
Are you ready for the spotlight? We're accepting content ideas for SAS Innovate 2025 to be held May 6-9 in Orlando, FL. The call is open until September 25. Read more here about why you should contribute and what is in it for you!
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.