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.

sas-innovate-2026-white.png



April 27 – 30 | Gaylord Texan | Grapevine, Texas

Registration is open

Walk in ready to learn. Walk out ready to deliver. This is the data and AI conference you can't afford to miss.
Register now and lock in 2025 pricing—just $495!

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
  • 3892 views
  • 0 likes
  • 8 in conversation