Hello community,
I've tried several different ways in an attempt to pass the location of the excel file to this macro.
But I keep getting nothing. My logs just showed the code I rant. So I started using option symbolgen and mlogic
to see if that would produce something for me. It did. It at least gave me the value of &path.
Also I did hard code this and it worked perfectly fine.
PLEASE HELP AND THANKS IN ADVANCE
I'm using Base SAS 9.4
options symbolgen mlogic;
%Let path = C:\mysdtm\SDTM_METADATA.xlsx;
%put NOTE: &path;
%macro make_blank_dataset(metadatafile=,dataset=);
proc import
datafile="&metadatafile"
out=_temp
options symbolgen mlogic;
%Let path = C:\mysdtm\SDTM_METADATA.xlsx;
%put NOTE: &path;
%macro make_empty_dataset(metadatafile=,dataset=);
proc import
datafile="&metadatafile"
out=_temp
dbms=excelcs
replace;
sheet="VARIABLE_METADATA";
run;
%mend make_empty_dataset;
%macro make_empty_dataset(path, AE);
dbms=excelcs
replace;
sheet="VARIABLE_METADATA";
run;
%mend make_empty_dataset;
%macro make_blank_dataset(path, AE);
Instead of
%macro make_empty_dataset(path, AE);
I think you need
%make_empty_dataset(metadatafile=&path, dataset=AE)
Although nowhere have you specified what AE is, and maccro variable &DATASET is not used in the macro.
Instead of
%macro make_empty_dataset(path, AE);
I think you need
%make_empty_dataset(metadatafile=&path, dataset=AE)
Although nowhere have you specified what AE is, and maccro variable &DATASET is not used in the macro.
You use the %MACRO statement when DEFINING a macro. Then CALLING the macro you just use its name.
Your log is not showing anything because it is still waiting for the %MEND statement to mark the end of the new definition for the macro.
To reference the VALUE or a macro variable you use & before the name of the macro variable.
When you define a macro parameter using = then it is considered a NAMED parameter instead of POSITIONAL parameter. You cannot pass value to named parameters without including the name in the macro call. (although you can pass values for positional parameters by including the name).
So your call should look like:
%make_empty_dataset(metadatafile=&path, dataset=AE)
Note that your macro never uses the value of the dataset parameter anywhere. Perhaps you want to change this section of the macro definition?
out=&dataset
Pretty much.
When you define the macro if the parameter name is NOT followed by the = then you CAN call it by position. When the parameter IS followed by the = then use MUST call it by name. You must define any positional parameters before any named parameters.
When calling the macro you can pass the positional parameter values in without their names, just by the position in the call. But you can also call them by their name if you want. Note that when calling the macro any values passed by position must appear before any named values. Also when passing values by name the order that the parameters appear in the call does not need to match the order that the parameters were defined in the %MACRO statement.
.
Registration is now open for SAS Innovate 2025 , our biggest and most exciting global event of the year! Join us in Orlando, FL, May 6-9.
Sign up by Dec. 31 to get the 2024 rate of just $495.
Register now!