How can I pass an alphanumeric value with a dot (e.g., PST.2) to a macro? Thanks.
options mprint; /* Makro zur Erstellung von PCT-Daten */ %macro create_ipay_pct9(input, output, pstn_value); data &output (keep=pstn area nmbr vl); set &input; if area not in (' ') or vl not= . then do; pstn = "&pstn_value"; end; run; %mend create_ipay_pct9; %create_ipay_pct9(ipay_pct9&year.&month, ipay_pct9_2&year.&month, PCT.2);
Thanks for pointing out the error in the macro. I've corrected the error and now it works as it should.
Hi,
Please share the code you have tried using the "Insert SAS Code" icon, and also share the log using the "Insert Code" icon ("</>").
I tried the following which appeared to work:
71 %macro test(arg); 72 %put The argument was &arg; 73 %mend test; 74 75 %test(PST.2); The argument was PST.2
Thanks & kind regards,
Amir.
It did'n work.
My macro:
%macro create_ipay_pct9(input, output, pstn_value);
data &output (keep=pstn area nmbr vl);
set &input;
if country not in (' ') or vl not= . then do;
%if %length(&pstn_value) > 0 %then %do;
pstn = &pstn_value;
%end;
end;
run;
%mend create_ipay_pct9;
My call:
%create_ipay_pct9(ipay_pct9&year.&month, ipay_pct9_2&year.&month, (PCT.2);
Hi,
Please post the full log using the Insert Code icon "</>".
Also your invocation looks like it has an extra "(":
%create_ipay_pct9(ipay_pct9&year.&month, ipay_pct9_2&year.&month, (PCT.2);
Thanks & kind regards,
Amir.
< I get the ERROR:
ERROR 386-185: Expecting an arithmetic expression.
ERROR 201-322: The option is not recognized and will be ignored.
call the macro:
%create_ipay_pct9(ipay_pct9&year.&month, ipay_pct9_2&year.&month, (PCT.2));
/>
Thanks
Hi,
Thanks for posting the log. When posting, there are icons above the text box, you can select the icon as below when posting the log:
You don't need the parenthesis around the value when calling the macro. Change the line of code from:
pstn = &pstn_value;
so that it has double quotes around the argument as it contains an alphanumeric value:
pstn = "&pstn_value";
Thanks & kind regards,
Amir.
no, it didn't work
</
%macro create_ipay_pct9(input, output, pstn_value);
data &output (keep=pstn area nmbr vl);
set &input;
if country not in (' ') or wert not= . then do;
%if %length(&pstn_value) > 0 %then %do;
pstn = "&pstn_value";
%end;
end;
run;
%mend create_ipay_pct9;
%create_ipay_pct9(ipay_pct9&year.&month, ipay_pct9_2&year.&month, (PCT2));
/>
my result:
Hi,
What is the length of the variable pstn on the data set, you might just need a length statement to capture longer length values.
Also you have no dot in the value in your latest post, so that is not the issue.
Lastly, see @PaigeMiller's advice as well as mine regarding logs, etc.
Thanks & kind regards,
Amir.
@Hoibai wrote:
< I get the ERROR:
ERROR 386-185: Expecting an arithmetic expression.
ERROR 201-322: The option is not recognized and will be ignored.
call the macro:
%create_ipay_pct9(ipay_pct9&year.&month, ipay_pct9_2&year.&month, (PCT.2));
/>
Thanks
Showing us partial logs like this doesn't help.
Since it is a macro, first turn on macro debugging option by running this command
options mprint;
and then run your macro again and show us the entire log for this macro. Post the log by copying it as text and pasting it into the window that appears when you click on the </> icon.
The Log:
</
1 ;*';*";*/;quit;run;
2 OPTIONS PAGENO=MIN;
3 %LET _CLIENTTASKLABEL='Programm 1';
4 %LET _CLIENTPROCESSFLOWNAME='Prozessfluss';
5 %LET _CLIENTPROJECTPATH='H:\My Documents\#Programm_Tabellen\A-SAS-Programme\XML_Ausgabe_Quartal_Final_20250312 .egp';
6 %LET _CLIENTPROJECTPATHHOST='AP923110';
7 %LET _CLIENTPROJECTNAME='XML_Ausgabe_Quartal_Final_20250312 .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
MLOGIC(HTML5ACCESSIBLEGRAPHSUPPORTED): Beginning execution.
MLOGIC(_SAS_VERCOMP_FV): Beginning execution.
MLOGIC(_SAS_VERCOMP_FV): Parameter FMAJOR has value 9
MLOGIC(_SAS_VERCOMP_FV): Parameter FMINOR has value 4
MLOGIC(_SAS_VERCOMP_FV): Parameter FMAINT has value 4
MLOGIC(_SAS_VERCOMP_FV): Parameter VMAJOR has value 0
MLOGIC(_SAS_VERCOMP_FV): Parameter VMINOR has value 0
MLOGIC(_SAS_VERCOMP_FV): Parameter VMAINT has value 0
MLOGIC(_SAS_VERCOMP_FV): %LOCAL MAJOR
MLOGIC(_SAS_VERCOMP_FV): %LOCAL MINOR
MLOGIC(_SAS_VERCOMP_FV): %LOCAL MAINT
MLOGIC(_SAS_VERCOMP_FV): %LOCAL CURMAJ
MLOGIC(_SAS_VERCOMP_FV): %LOCAL CURMIN
MLOGIC(_SAS_VERCOMP_FV): %LOCAL CURMNT
MLOGIC(_SAS_VERCOMP_FV): %LET (variable name is CURMAJ)
MLOGIC(_SAS_VERCOMP_FV): %IF condition %eval(&CurMaj EQ V) is FALSE
MLOGIC(_SAS_VERCOMP_FV): %LET (variable name is MAJOR)
MLOGIC(_SAS_VERCOMP_FV): %LET (variable name is MINOR)
MLOGIC(_SAS_VERCOMP_FV): %LET (variable name is MAINT)
MLOGIC(_SAS_VERCOMP_FV): %LET (variable name is CURMIN)
MLOGIC(_SAS_VERCOMP_FV): %LET (variable name is CURMNT)
MLOGIC(_SAS_VERCOMP_FV): %IF condition %eval(&major NE &CurMaj) is FALSE
MLOGIC(_SAS_VERCOMP_FV): %IF condition %eval(&minor NE &CurMin) is FALSE
MLOGIC(_SAS_VERCOMP_FV): %IF condition "&maint" = "" is FALSE
MLOGIC(_SAS_VERCOMP_FV): Ending execution.
MLOGIC(HTML5ACCESSIBLEGRAPHSUPPORTED): %IF condition %_SAS_VERCOMP_FV(9,4,4, 0,0,0) >= 0 is TRUE
MPRINT(HTML5ACCESSIBLEGRAPHSUPPORTED): ACCESSIBLE_GRAPH
MLOGIC(HTML5ACCESSIBLEGRAPHSUPPORTED): Ending execution.
21 ENCODING='utf-8'
22 STYLE=HtmlBlue
23 NOGTITLE
24 NOGFOOTNOTE
25 GPATH=&sasworklocation
26 ;
NOTE: Writing HTML5(EGHTML) Body file: EGHTML
27
28 options mprint;
29 /* Makro zur Erstellung von PCT-Daten */
2 The SAS System 12:59 Thursday, May 15, 2025
30 %macro create_ipay_pct9(input, output, pstn_value);
31 data &output (keep=pstn area nmbr vl);
32 set &input;
33 if country not in (' ') or wert not= . then do;
34 %if %length(&pstn_value) > 0 %then %do;
35 pstn = "&pstn_value";
36 %end;
37 end;
38 run;
39 %mend create_ipay_pct9;
40 %create_ipay_pct9(ipay_pct9&year.&month, ipay_pct9_2&year.&month, (PCT2));
MLOGIC(CREATE_IPAY_PCT9): Beginning execution.
MLOGIC(CREATE_IPAY_PCT9): Parameter INPUT has value ipay_pct9202504
MLOGIC(CREATE_IPAY_PCT9): Parameter OUTPUT has value ipay_pct9_2202504
MLOGIC(CREATE_IPAY_PCT9): Parameter PSTN_VALUE has value (PCT2)
MPRINT(CREATE_IPAY_PCT9): data ipay_pct9_2202504 (keep=pstn area nmbr vl);
MPRINT(CREATE_IPAY_PCT9): set ipay_pct9202504;
MPRINT(CREATE_IPAY_PCT9): if country not in (' ') or wert not= . then do;
MLOGIC(CREATE_IPAY_PCT9): %IF condition %length(&pstn_value) > 0 is TRUE
MPRINT(CREATE_IPAY_PCT9): pstn = "(PCT2)";
MPRINT(CREATE_IPAY_PCT9): end;
MPRINT(CREATE_IPAY_PCT9): run;
NOTE: Variable country is uninitialized.
NOTE: Variable wert is uninitialized.
NOTE: There were 28 observations read from the data set WORK.IPAY_PCT9202504.
NOTE: The data set WORK.IPAY_PCT9_2202504 has 28 observations and 4 variables.
NOTE: Compressing data set WORK.IPAY_PCT9_2202504 increased size by 100.00 percent.
Compressed is 2 pages; un-compressed would require 1 pages.
NOTE: DATA statement used (Total process time):
real time 0.00 seconds
cpu time 0.00 seconds
MLOGIC(CREATE_IPAY_PCT9): Ending execution.
41
42
43 %LET _CLIENTTASKLABEL=;
44 %LET _CLIENTPROCESSFLOWNAME=;
45 %LET _CLIENTPROJECTPATH=;
46 %LET _CLIENTPROJECTPATHHOST=;
47 %LET _CLIENTPROJECTNAME=;
48 %LET _SASPROGRAMFILE=;
49 %LET _SASPROGRAMFILEHOST=;
50
51 ;*';*";*/;quit;run;
52 ODS _ALL_ CLOSE;
53
54
55 QUIT; RUN;
/>
In case you missed my earlier post:
I'll take those out:
</
%if %length(&pstn_value) > 0 %then %do;
/>
but it didn't do it either.
you need to read carefully
We want the entire log of the MACRO and not the approx 50 lines before %create_ipay_pct9 and after the macro ends, we don't need anything after the NOTES at the bottom of the run of the macro.
You need to click on the </> icon to open a window to paste the log into. This has been mentioned at least 3 times now, please do this.
We don't need the MLOGIC option turned on, just MPRINT
1 ;*';*";*/;quit;run; 2 OPTIONS PAGENO=MIN; 3 %LET _CLIENTTASKLABEL='Programm 1'; 4 %LET _CLIENTPROCESSFLOWNAME='Prozessfluss'; 5 %LET _CLIENTPROJECTPATH='H:\My Documents\#Programm_Tabellen\A-SAS-Programme\XML_Ausgabe_Quartal_Final_20250312 .egp'; 6 %LET _CLIENTPROJECTPATHHOST='AP923110'; 7 %LET _CLIENTPROJECTNAME='XML_Ausgabe_Quartal_Final_20250312 .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 MLOGIC(HTML5ACCESSIBLEGRAPHSUPPORTED): Beginning execution. MLOGIC(_SAS_VERCOMP_FV): Beginning execution. MLOGIC(_SAS_VERCOMP_FV): Parameter FMAJOR has value 9 MLOGIC(_SAS_VERCOMP_FV): Parameter FMINOR has value 4 MLOGIC(_SAS_VERCOMP_FV): Parameter FMAINT has value 4 MLOGIC(_SAS_VERCOMP_FV): Parameter VMAJOR has value 0 MLOGIC(_SAS_VERCOMP_FV): Parameter VMINOR has value 0 MLOGIC(_SAS_VERCOMP_FV): Parameter VMAINT has value 0 MLOGIC(_SAS_VERCOMP_FV): %LOCAL MAJOR MLOGIC(_SAS_VERCOMP_FV): %LOCAL MINOR MLOGIC(_SAS_VERCOMP_FV): %LOCAL MAINT MLOGIC(_SAS_VERCOMP_FV): %LOCAL CURMAJ MLOGIC(_SAS_VERCOMP_FV): %LOCAL CURMIN MLOGIC(_SAS_VERCOMP_FV): %LOCAL CURMNT MLOGIC(_SAS_VERCOMP_FV): %LET (variable name is CURMAJ) MLOGIC(_SAS_VERCOMP_FV): %IF condition %eval(&CurMaj EQ V) is FALSE MLOGIC(_SAS_VERCOMP_FV): %LET (variable name is MAJOR) MLOGIC(_SAS_VERCOMP_FV): %LET (variable name is MINOR) MLOGIC(_SAS_VERCOMP_FV): %LET (variable name is MAINT) MLOGIC(_SAS_VERCOMP_FV): %LET (variable name is CURMIN) MLOGIC(_SAS_VERCOMP_FV): %LET (variable name is CURMNT) MLOGIC(_SAS_VERCOMP_FV): %IF condition %eval(&major NE &CurMaj) is FALSE MLOGIC(_SAS_VERCOMP_FV): %IF condition %eval(&minor NE &CurMin) is FALSE MLOGIC(_SAS_VERCOMP_FV): %IF condition "&maint" = "" is FALSE MLOGIC(_SAS_VERCOMP_FV): Ending execution. MLOGIC(HTML5ACCESSIBLEGRAPHSUPPORTED): %IF condition %_SAS_VERCOMP_FV(9,4,4, 0,0,0) >= 0 is TRUE MPRINT(HTML5ACCESSIBLEGRAPHSUPPORTED): ACCESSIBLE_GRAPH MLOGIC(HTML5ACCESSIBLEGRAPHSUPPORTED): Ending execution. 21 ENCODING='utf-8' 22 STYLE=HtmlBlue 23 NOGTITLE 24 NOGFOOTNOTE 25 GPATH=&sasworklocation 26 ; NOTE: Writing HTML5(EGHTML) Body file: EGHTML 27 28 options mprint; 29 /* Makro zur Erstellung von PCT-Daten */ 2 The SAS System 12:59 Thursday, May 15, 2025 30 %macro create_ipay_pct9(input, output, pstn_value); 31 data &output (keep=pstn area nmbr vl); 32 set &input; 33 if country not in (' ') or wert not= . then do; 34 pstn = "&pstn_value"; 35 end; 36 run; 37 %mend create_ipay_pct9; 38 %create_ipay_pct9(ipay_pct9&year.&month, ipay_pct9_2&year.&month, (PCT2)); MLOGIC(CREATE_IPAY_PCT9): Beginning execution. MLOGIC(CREATE_IPAY_PCT9): Parameter INPUT has value ipay_pct9202504 MLOGIC(CREATE_IPAY_PCT9): Parameter OUTPUT has value ipay_pct9_2202504 MLOGIC(CREATE_IPAY_PCT9): Parameter PSTN_VALUE has value (PCT2) MPRINT(CREATE_IPAY_PCT9): data ipay_pct9_2202504 (keep=pstn area nmbr vl); MPRINT(CREATE_IPAY_PCT9): set ipay_pct9202504; MPRINT(CREATE_IPAY_PCT9): if country not in (' ') or wert not= . then do; MPRINT(CREATE_IPAY_PCT9): pstn = "(PCT2)"; MPRINT(CREATE_IPAY_PCT9): end; MPRINT(CREATE_IPAY_PCT9): run; NOTE: Variable country is uninitialized. NOTE: Variable wert is uninitialized. NOTE: There were 28 observations read from the data set WORK.IPAY_PCT9202504. NOTE: The data set WORK.IPAY_PCT9_2202504 has 28 observations and 4 variables. NOTE: Compressing data set WORK.IPAY_PCT9_2202504 increased size by 100.00 percent. Compressed is 2 pages; un-compressed would require 1 pages. NOTE: DATA statement used (Total process time): real time 0.01 seconds cpu time 0.00 seconds MLOGIC(CREATE_IPAY_PCT9): Ending execution. 39 40 41 %LET _CLIENTTASKLABEL=; 42 %LET _CLIENTPROCESSFLOWNAME=; 43 %LET _CLIENTPROJECTPATH=; 44 %LET _CLIENTPROJECTPATHHOST=; 45 %LET _CLIENTPROJECTNAME=; 46 %LET _SASPROGRAMFILE=; 47 %LET _SASPROGRAMFILEHOST=; 48 49 ;*';*";*/;quit;run; 50 ODS _ALL_ CLOSE; 51 52 53 QUIT; RUN; 54
Hi,
What is the length of the variable pstn on the data set?
Thanks & kind regards,
Amir.
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.
Ready to level-up your skills? Choose your own adventure.