BookmarkSubscribeRSS Feed
Robert_Bardos
Fluorite | Level 6
8-( [sheer nonsense removed ... testing under DMS has its quirks ... should have been more careful, sorry]


Message was edited by: Robert.Bardos
FloydNevseta
Pyrite | Level 9
Change your "and" to "or", and it will work as expected.

> %if %scan(&months,&month) ^= mar and &year^=1997 %then %do;

Since both your conditions are negations, the only way for the expression to evaluate to false for Mar 1997 and execute the else is when the 2 conditions are OR'ed. Thus, the expression is always true when the month is not Mar or the year is not 1997.

hackathon24-white-horiz.png

2025 SAS Hackathon: There is still time!

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!

Register Now

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.

SAS Training: Just a Click Away

 Ready to level-up your skills? Choose your own adventure.

Browse our catalog!

Discussion stats
  • 16 replies
  • 3476 views
  • 0 likes
  • 8 in conversation