BookmarkSubscribeRSS Feed
🔒 This topic is solved and locked. Need further help from the community? Please sign in and ask a new question.
Tom
Super User Tom
Super User

Sounds like you need to learn about how SAS macros work. The main thing to understand is that the macro logic just generates text that is then treated by plain old SAS the same as if that text had been typed as the original program.

Did you even have a macro to begin with in the original program that you are trying to update?

The snippet of code you included in your original code is normal SAS code that would be part of a DATA step.  It is using macro VARIABLES to store values so that the code is little easier to edit, but it did not include any conditional logic (MACRO logic) that would require that it be part of a macro rather than open code.

The main problem with your attempt to modify the program is the LOGIC of what you are trying to do.  You appear to want to test if one list is in another list.  That syntax does not even exist. What did you mean by the condition (&dxlist in 'I420' 'I425' 'I426' )?

Are you asking if all of the codes in DXLIST are one of these three codes?  Or perhaps the other way around, whether all three of these codes are in DXLIST?

Maybe you want it to be true when any of the codes in DXLIST are in the other list?

If you look at the logic of your original data step code you can see that what you need to do is index over one of these lists and compare an individual value from that list to the other list.

If you cannot use the IN operator you could probably do what you want using the INDEXW function instead, but you will probably need to remove all of those quotes.  For example you could replace ('XYZ' in ('123','abc','XYZ')) with indexw('123 abc XYZ','XYZ'). 

SAS Innovate 2025: Call for Content

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!

Submit your idea!

How to Concatenate Values

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.

Click image to register for webinarClick image to register for webinar

Classroom Training Available!

Select SAS Training centers are offering in-person courses. View upcoming courses for:

View all other training opportunities.

Discussion stats
  • 15 replies
  • 44504 views
  • 4 likes
  • 4 in conversation