BookmarkSubscribeRSS Feed
🔒 This topic is solved and locked. Need further help from the community? Please sign in and ask a new question.
MeganE
Pyrite | Level 9

HI all,

 

I have a macro that resolves a "&&byyear&i" into "E&M Nephrologist" and SAS keeps trying to resolve the & in E&M.  There's no error, just a warning in the log, but due to the fact that it's in code that takes a while to run, i have set it up to check &syserr and only continue when syserr=0.  But warnings are not zeros, so the code is stopping.

 

So i've updated the code that looked only for syserr=0 and changed it to syserr in (0 4), but it got me to thinking, is there a way to tell sas to ignore the & in the E&M, while at the same time, not ignore the &&byyear&i?

 

I need the &&byyear&i in double quotes or it won't resolve.

 

Any ideas?

 

 

 

1 ACCEPTED SOLUTION

Accepted Solutions
PaigeMiller
Diamond | Level 26

"%superq(byyear&ii)"

--
Paige Miller

View solution in original post

6 REPLIES 6
ballardw
Super User

It may help get a better answer by showing the code where you are using this.

PaigeMiller
Diamond | Level 26

"%superq(byyear&ii)"

--
Paige Miller
RW9
Diamond | Level 26 RW9
Diamond | Level 26

2 things.  Firstly why would a macro variable named by year, come out with that text?  Either naming is wrong or result is wrong.

Secondly, show the process.  A rule of thumb, if you see more than one & anywhere in code then there is 100% chance of refactoring the code to be much simpler and easier to understand.  

PaigeMiller
Diamond | Level 26

@RW9 wrote:

2 things.  Firstly why would a macro variable named by year, come out with that text?  Either naming is wrong or result is wrong.


Really, isn't this irrelevant to solving the problem?

 

Secondly, show the process. A rule of thumb, if you see more than one & anywhere in code then there is 100% chance of refactoring the code to be much simpler and easier to understand.

 I myself have sometimes fallen into the trap of telling people that there's only one right tool in SAS to solve the problem. But, what is the "right" way to solve a problem to you, and "simpler and easier to understand" to you, may not be the right tool for others and may be much more complicated and difficult to understand. I have no problem with code that contains &&, there are many situations where it has been useful to me.

--
Paige Miller
RW9
Diamond | Level 26 RW9
Diamond | Level 26

"Really, isn't this irrelevant to solving the problem?"

Yes, it may be that the macro variable itself is not reolving correctly, or using the wrong data leading to the issue.  Byyear would indicate a variable should resolve to a year value, so why is the & appearing in such a way?

 

"byyear" - this in itself indicates by group processing.  If you feel having several && and convoluted methods to debug such code as against by group processing which is a fundamental concept of SAS, then good for you.

MeganE
Pyrite | Level 9

Don't worry about what i name my macros.  It was supposed to resolve to E&M Nephrology and it did.  There is no error in my code.

 

The question i posted about was, how can i get sas to ignore the & in the E&M Nephrology value while not ignoring the & it has to resolve to get there.

 

 

sas-innovate-2024.png

Join us for SAS Innovate April 16-19 at the Aria in Las Vegas. Bring the team and save big with our group pricing for a limited time only.

Pre-conference courses and tutorials are filling up fast and are always a sellout. Register today to reserve your seat.

 

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.

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
  • 6 replies
  • 690 views
  • 0 likes
  • 4 in conversation