Hello,
I have this spec for ANRIND
Here is a sample of the data
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|5.0, 6.0, 7.0, 8.0|NORMAL|7.0
1001|5.0, 6.0, 7.0, 8.0|NORMAL|6.0
1001|Negative|ABNORMAL|5
1001|None, Occasional, 1-2|NORMAL|Occasional
1001|None, Occasional, 1-5|NORMAL|1-5
;
What is the best approach here? I know I could just do INDEX ,FIND, PRXCHANGE for matching but what is the best way to approach the comma separated variables and to make sure LBSTNRC and AVALC match and to account for the condition when they don't?
Is AVALC ever more than that "one word" sort of appearance? If not, I don't understand the $200. input. If so, then you need to provide other examples of values of the AVALC variable.
My first feeling would be to use the FINDW function as you can specify the delimiter.
something like
if findw(lbstrnrc,strip(avalc),', ')>0 then <what you want to do when found> else <what to do when not found>;
Strip is likely needed as you have defined AVALC as 200 characters in your example and would be looking for all 200 in the FINDW (or Find and Index or indexw functions)
Add in a Not missing(variable) to require the presence of a value where needed.
Is AVALC ever more than that "one word" sort of appearance? If not, I don't understand the $200. input. If so, then you need to provide other examples of values of the AVALC variable.
My first feeling would be to use the FINDW function as you can specify the delimiter.
something like
if findw(lbstrnrc,strip(avalc),', ')>0 then <what you want to do when found> else <what to do when not found>;
Strip is likely needed as you have defined AVALC as 200 characters in your example and would be looking for all 200 in the FINDW (or Find and Index or indexw functions)
Add in a Not missing(variable) to require the presence of a value where needed.
Perfect thanks!
Good news: We've extended SAS Hackathon registration until Sept. 12, so you still have time to be part of our biggest event yet – our five-year anniversary!
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.
Ready to level-up your skills? Choose your own adventure.