I'm a complete novice w/ macros and this syntax produces an error I don't know how to rectify. Thanks for your help.
%LET macro = /home/maldini/EPG1V2/data/StormStats.xlsx;
ODS EXCEL FILE=¯o
STYLE=snow
OPTIONS (SHEET_NAME="South Pacific Summary");
TITLE "Some Relevant Title";
ODS NOPROCTITLE;
proc means data=pg1.storm_detail maxdec=0 median max;
class Season;
var Wind;
where Basin='SP' and Season in (2014,2015,2016);
run;
ODS EXCEL CLOSE;
Here is the log:
1 OPTIONS NONOTES NOSTIMER NOSOURCE NOSYNTAXCHECK;
NOTE: ODS statements in the SAS Studio environment may disable some output features.
73
74 %LET macro = /home/maldini/EPG1V2/data/StormStats.xlsx;
75
76 ODS EXCEL FILE=¯o
77 STYLE=snow
NOTE: Line generated by the macro variable "MACRO".
77 /home/jcorroon/EPG1V2/data/StormStats.xlsx
_
22
200
ERROR 22-322: Syntax error, expecting one of the following: a name, a quoted string.
ERROR 200-322: The symbol is not recognized and will be ignored.
78
79 OPTIONS (SHEET_NAME="South Pacific Summary");
80
81 TITLE "Some Relevant Title";
82 ODS NOPROCTITLE;
83
84 proc means data=pg1.storm_detail maxdec=0 median max;
85 class Season;
86 var Wind;
87 where Basin='SP' and Season in (2014,2015,2016);
88 run;
NOTE: There were 1132 observations read from the data set PG1.STORM_DETAIL.
WHERE (Basin='SP') and Season in (2014, 2015, 2016);
NOTE: PROCEDURE MEANS used (Total process time):
real time 0.05 seconds
user cpu time 0.04 seconds
system cpu time 0.01 seconds
memory 12025.96k
OS Memory 44052.00k
Timestamp 04/28/2022 06:04:03 PM
Step Count 58 Switch Count 3
Page Faults 0
Page Reclaims 2761
Page Swaps 0
Voluntary Context Switches 30
Involuntary Context Switches 0
Block Input Operations 0
Block Output Operations 8
89
90 ODS EXCEL CLOSE;
91
92
93 OPTIONS NONOTES NOSTIMER NOSOURCE NOSYNTAXCHECK;
105
Looks like you are asking about a macro variable (aka symbol) and not an actual macro.
The macro processor is just doing text replacement. So to tell if expanding a macro variable in your code will produce value syntax just replace the reference with the value.
So for:
FILE=¯o
You will get :
FILE=/home/maldini/EPG1V2/data/StormStats.xlsx
Which not valid SAS syntax. The value of the FILE= option needs to be either a FILEREF or a quoted physical filename.
Try:
FILE="¯o"
instead.
Or add the quotes into the value of the macro variable.
%LET macro = "/home/maldini/EPG1V2/data/StormStats.xlsx" ;
ODS EXCEL FILE=¯o
...
Looks like you are asking about a macro variable (aka symbol) and not an actual macro.
The macro processor is just doing text replacement. So to tell if expanding a macro variable in your code will produce value syntax just replace the reference with the value.
So for:
FILE=¯o
You will get :
FILE=/home/maldini/EPG1V2/data/StormStats.xlsx
Which not valid SAS syntax. The value of the FILE= option needs to be either a FILEREF or a quoted physical filename.
Try:
FILE="¯o"
instead.
Or add the quotes into the value of the macro variable.
%LET macro = "/home/maldini/EPG1V2/data/StormStats.xlsx" ;
ODS EXCEL FILE=¯o
...
It's finally time to hack! Remember to visit the SAS Hacker's Hub regularly for news and updates.
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.