while executing below code of IN operator , the Block resolves to ERROR instead of Hello , when i pass input parameter as FI
%macro test(a) /minoperator;
%if %upcase(&a) in (FI BI CA) %then %put Hello;
%else %put ERROR;
%mend test;
%test(FI)
here is the Log :
1 The SAS System Friday, September 17, 2021 08:57:00 AM
1 ;*';*";*/;quit;run;
2 OPTIONS PAGENO=MIN;
3 %LET _CLIENTTASKLABEL='Program 6';
4 %LET _CLIENTPROCESSFLOWNAME='Process Flow';
5 %LET _CLIENTPROJECTPATH='C:\Users\B723166\Desktop\Test23.egp';
6 %LET _CLIENTPROJECTPATHHOST='OPJTYTRU99146';
7 %LET _CLIENTPROJECTNAME='Test23.egp';
8 %LET _SASPROGRAMFILE='';
9 %LET _SASPROGRAMFILEHOST='';
10
11 ODS _ALL_ CLOSE;
12 OPTIONS DEV=SVG;
13 GOPTIONS XPIXELS=0 YPIXELS=0;
14 %macro HTML5AccessibleGraphSupported;
15 %if %_SAS_VERCOMP_FV(9,4,4, 0,0,0) >= 0 %then ACCESSIBLE_GRAPH;
16 %mend;
17 FILENAME EGHTML TEMP;
18 ODS HTML5(ID=EGHTML) FILE=EGHTML
19 OPTIONS(BITMAP_MODE='INLINE')
20 %HTML5AccessibleGraphSupported
21 ENCODING='utf-8'
22 STYLE=HtmlBlue
23 NOGTITLE
24 NOGFOOTNOTE
25 GPATH=&sasworklocation
26 ;
NOTE: Writing HTML5(EGHTML) Body file: EGHTML
27
28 %macro test(a) /minoperator;
29
30 %if %upcase(&a) in (FI BI CA) %then %put Hello;
31 %else %put ERROR;
32 %mend test;
33
34 %test(FI)
ERROR
35
36 %LET _CLIENTTASKLABEL=;
37 %LET _CLIENTPROCESSFLOWNAME=;
38 %LET _CLIENTPROJECTPATH=;
39 %LET _CLIENTPROJECTPATHHOST=;
40 %LET _CLIENTPROJECTNAME=;
41 %LET _SASPROGRAMFILE=;
42 %LET _SASPROGRAMFILEHOST=;
43
44 ;*';*";*/;quit;run;
45 ODS _ALL_ CLOSE;
46
47
48 QUIT; RUN;
49
You are missing quoting from %if %upcase(&a) in (FI BI CA) %then %put Hello;
Try : %if %upcase(&a) in ('FI','BI','CA') %then %put Hello;
You are missing quoting from %if %upcase(&a) in (FI BI CA) %then %put Hello;
Try : %if %upcase(&a) in ('FI','BI','CA') %then %put Hello;
This accepted solution looks wrong to me. You shouldn't need quote marks in the macro language, as shown in the log I posted showing that the original code posted in the question works correctly.
I agree, @Quentin . The solution marked correct, in fact is not correct.
@learn_SAS_23 Please un-mark that solution as correct.
Remember to use the Options Minoperator.
Your code runs fine for me:
1 %macro test(a) /minoperator; 2 3 %if %upcase(&a) in (FI BI CA) %then %put Hello; 4 %else %put ERROR; 5 %mend test; 6 7 %test(FI) Hello
Thanks for all valuable inputs it works now.
Build your skills. Make connections. Enjoy creative freedom. Maybe change the world. Registration is now open through August 30th. Visit the SAS Hackathon homepage.
Register today!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.
Select SAS Training centers are offering in-person courses. View upcoming courses for: