Search code examples
variablessasfilepathsas-macro

Combine two strings for file path in SAS


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.


Solution

  • I reckon you meant to use QUOTE function.

    %sysfunc(quote(&CompInputDirect))
    

    Or you can supply your own quotes.

    "&CompInputDirect"