Reputation: 133
I have two strings that I want to combine to get the file path to be used in a PROC IMPORT statement in SAS
%let TypeName = XYZ;
%let InputDirectory = \\Nam1\Nam2\Nam3\Dataset\;
%let FileType = Filing.csv;
%let Filename = &TypeName&FileType;
%put &Filename;
%let CompInputDirect = &InputDirectory&Filename;
PROC IMPORT DATAFILE= %sysfunc(&CompInputDirect)
OUT= outdata
DBMS=csv
REPLACE;
GETNAMES=YES;
RUN;
I get an error message saying that
ERROR: Function name missing in %SYSFUNC or %QSYSFUNC macro function reference.
How do I put a macro variable containing the full file path in the Proc Import statement? Thanks in advance.
Upvotes: 1
Views: 1453
Reputation: 27526
Macro symbol resolution &<name>
is more formally &<name>.
The .
is often left off when the resolution occurs where other characters or tokens break up the submit stream.
You want to be careful if you have abstracted a dot (.
) filename extension. You will need double dots in order to resolve filename and dot separate the extension. A good habit when dealing with filename parts is to use the formal resolution syntax.
Example:
%let folder = \\Nam1\Nam2\Nam3\Dataset\;
%let file = XYZ;
%let ext = csv;
proc import datafile = "&folder.&file..&ext." ...
^^
Upvotes: 2
Reputation: 9109
I reckon you meant to use QUOTE function.
%sysfunc(quote(&CompInputDirect))
Or you can supply your own quotes.
"&CompInputDirect"
Upvotes: 3