Building models with SAS Enterprise Miner, SAS Factory Miner, SAS Visual Data Mining and Machine Learning or just with programming

Why the macro in not giving any output?

Accepted Solution Solved
Reply
Contributor
Posts: 49
Accepted Solution

Why the macro in not giving any output?

Can any one help me here?

%macro one;

%if %index("devara", "deva")  %then %put exists;

%mend;

%one;

Thank you in advance


Accepted Solutions
Solution
‎11-06-2013 10:50 AM
Super User
Posts: 10,483

Re: Why the macro in not giving any output?

Also confusing the rules for strings between macro and datastep code.

Try using this line:

 

%if %index(devara, deva) %then %put exists

Macro literals do not need quotes to delimit but data step string literals do. Since macro variables would be reference by &var then without the & the macro processor treats what follows as string literal.

And you original code failed because "deva" did not occur within the source string.

View solution in original post


All Replies
Trusted Advisor
Posts: 1,128

Re: Why the macro in not giving any output?

the above macro is working, however since the index function is unable to find the text "deva" including the quotes in "devara" it is not displaying anything in the log. Please try the below code and check the log you will find not exists in the log.

%macro one;

%if %index("devara", "deva")  %then %put exists;

%else %put not exists;

%mend;

%one;

Thanks,
Jag
Solution
‎11-06-2013 10:50 AM
Super User
Posts: 10,483

Re: Why the macro in not giving any output?

Also confusing the rules for strings between macro and datastep code.

Try using this line:

 

%if %index(devara, deva) %then %put exists

Macro literals do not need quotes to delimit but data step string literals do. Since macro variables would be reference by &var then without the & the macro processor treats what follows as string literal.

And you original code failed because "deva" did not occur within the source string.

☑ This topic is SOLVED.

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

Discussion stats
  • 2 replies
  • 245 views
  • 0 likes
  • 3 in conversation