I have a dataset like the one below.
I wish to extra the id where the variable "atc" only has "A10A".
So, in this example, I would extract id=282 and id=299.
Does anyone know how to achieve this in SAS? Thank you!!
It would be extremely helpful, in this problem and all future problems, if you SHOW US the desired output.
Since you haven't done that, please do so now. Please also explain why rows 1 and 2, where atc="A10A" are not in the output.
Thanks for your reply.
The output I'd like to have is:
Rows 1 and 2 should not be in the output, because the atc value for id "233" is not restricted to "A10A". For example, id 233 also has atc value of "C05", "V90A" etc.
Thanks for you reply Tom. Your solution works!
May I further ask does "if last.lopnr and not other" always do the same as "if last.lopnr and other=0"?
In this case yes. But in the general case it is more like
if last.lopnr and (other=0 or missing(other));
SAS will evaluate a zero or missing value as FALSE and any other value as TRUE.
SAS is headed back to Vegas for an AI and analytics experience like no other! Whether you're an executive, manager, end user or SAS partner, SAS Innovate is designed for everyone on your team.
Interested in speaking? Content from our attendees is one of the reasons that makes SAS Innovate such a special event!
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.