Need help with a Macro formula

Accepted Solution Solved
Reply
Contributor
Posts: 59
Accepted Solution

Need help with a Macro formula

Hello all. I am trying to create this Macro

 

%LET CODE = svc.BILL_SVC_UNIT_1_CD >= 'L0220' and svc.BILL_SVC_UNIT_1_CD <='L4631' and svc.BILL_SVC_UNIT_1_CD = '97760';

 

I have tried putting parenthesis around it in various ways but it still doesnt work. It will work if I took off the 97760 portion but I need that. The only other option is to include each and every  L code which as one can see is a considerable amount.

 

Any assistance would be greatly appreciated.

 

Thanks


Accepted Solutions
Solution
‎01-24-2018 02:54 PM
Contributor
Posts: 59

Re: Need help with a Macro formula

Posted in reply to wheddingsjr
I think I got it. It should be OR instead of AND..its now running. Thanks Astounding and Reeza

View solution in original post


All Replies
Super User
Posts: 23,776

Re: Need help with a Macro formula

Posted in reply to wheddingsjr

What are you expecting to come out of that formula?

 

svc.BILL_SVC_UNIT_1_CD is a variable in a data set, but the macro processor won't have access. 

 

I suspect you may need a different approach to whatever problem you're trying to solve.

Super User
Posts: 6,785

Re: Need help with a Macro formula

Posted in reply to wheddingsjr

This code is 100% fine.  It does exactly what it is supposed to do.  It assigns a long value to a macro variable named CODE.

 

Why do you say it is not working?  Show the log.

Contributor
Posts: 59

Re: Need help with a Macro formula

Posted in reply to Astounding

Thanks Astounding. I was under the same impression. As I stated, it works as long as I do not use the last part. Its when I include it I get no results. The log has no errors it just doesn't produce any lines. If I take off the last part (with the 97760) I get a few thousand lines.

Super User
Posts: 23,776

Re: Need help with a Macro formula

Posted in reply to wheddingsjr

Well  that last condition is probably mutually exclusive from the first two so it doesn't include any data because nothing meets both conditions. There's nothing wrong with the syntax but the logic is flawed.

 

Did you mean to have an OR instead of AND?

svc.BILL_SVC_UNIT_1_CD >= 'L0220' and svc.BILL_SVC_UNIT_1_CD<='L4631' 

and svc.BILL_SVC_UNIT_1_CD = '97760'; 

wheddingsjr wrote:

Thanks Astounding. I was under the same impression. As I stated, it works as long as I do not use the last part. Its when I include it I get no results. The log has no errors it just doesn't produce any lines. If I take off the last part (with the 97760) I get a few thousand lines.


 

Contributor
Posts: 59

Re: Need help with a Macro formula

Reeza...looks like we came to the same conclussion at the same time. As I was thinking about the OR instead of AND I see you asked the same question...lol

Contributor
Posts: 59

Re: Need help with a Macro formula

Posted in reply to Astounding

I use this macro coding everyday as part of my job, its the combination that is not working. If I were to exclude the => <= portion and just run the 97760, again I get results. Perhaps I should use "OR" instead of "AND"?

Solution
‎01-24-2018 02:54 PM
Contributor
Posts: 59

Re: Need help with a Macro formula

Posted in reply to wheddingsjr
I think I got it. It should be OR instead of AND..its now running. Thanks Astounding and Reeza
Super User
Posts: 23,776

Re: Need help with a Macro formula

Posted in reply to wheddingsjr

Make sure to include parenthesis to properly have the AND and OR evaluate correctly. 

I'm assuming this is likely what you want:

 

(svc.BILL_SVC_UNIT_1_CD >= 'L0220' and svc.BILL_SVC_UNIT_1_CD <='L4631') OR svc.BILL_SVC_UNIT_1_CD = '97760';

Contributor
Posts: 59

Re: Need help with a Macro formula

Reeza, I had already run it without the parenthesis but to be on the safe side and to compare I ran it WITH the parenthesis and got 5 more lines than when not using the parenthesis. Going to have to reconcile the two. Thanks for your help!!!

Super User
Posts: 13,583

Re: Need help with a Macro formula

Posted in reply to wheddingsjr

You want to be very careful when using < or > comparisons with string values. If you think "L5" < "L4631" you might be somewhat surprised at results. Also for consideration are comparisons where capitalization of characters gets involved. Lower case letters are "greater than" their uppercase equivalents.

☑ This topic is solved.

Need further help from the community? Please ask a new question.

Discussion stats
  • 10 replies
  • 182 views
  • 2 likes
  • 4 in conversation