DATA Step, Macro, Functions and more

creating a variable using another categorical one

Reply
Frequent Contributor
Posts: 110

creating a variable using another categorical one

[ Edited ]
rx name
1 clozipine hyrochloride
2 clozipine
3 terazip
3 terazip hydrochloride
4 asipirin 

Hi all,

I know this is a simple question but I am trying to find the most efficient way to resolve it. I want to group id who have clozpine and terazip togethe. There are so many rxs that would need to be grouped together, I was thinking about substr but I got an error. 

if substr, x, i, 1,7 in (clzpinee, terazip) then do

 

Super User
Posts: 5,082

Re: creating a variable using another categorical one

This might be the easiest way to say it:

 

if name in : ('clozipine ', 'terazip ') then do;

 

It's up to you whether you want to include the blank at the end of the compound name.

Ask a Question
Discussion stats
  • 1 reply
  • 142 views
  • 0 likes
  • 2 in conversation