Hello, This is a follow up from a previous post
https://communities.sas.com/t5/SAS-Programming/Populating-variable-based-on-matching-phrases/m-p/833700#M329591
This is the code I wrote based off the response
data have;
input USUBJID $ LBSTNRC :$40. LBNRIND :$14. AVALC :$200.;
infile datalines dlm = '|';
datalines;
1001|Negative|NORMAL|Negative
1001|5.0, 6.0, 7.0, 8.0|NORMAL|6.0
1001|6.0, 7.0, 8.0, 9.0|NORMAL|7.0
1001|5.0, 6.0, 7.0, 8.0|NORMAL|5.0
1001|Negative|ABNORMAL|5
1001|None, Occasional, 1-2|NORMAL|Occasional
1001|None, Occasional, 1-5|NORMAL|None
;
* ANRIND *;
if lbstrnc ne '' then do;
if findw(lbstnrc,strip(avalc),', ')>0 then anrind ='Normal';
end;
if missing(lbstnrc) then anrind = propcase(lbnrind,'/');
However, I misinterpreted the spec requirements and it should be set to Normal for results that have comma separated values only. Also, the code provided does not work if the value is the first value in the LBSTNC e.g. row 4 or row 7 in data provided?. How can I amend this?
... View more