Help using Base SAS procedures

concatenating with filenames

Posts: 0

concatenating with filenames

This might seem confusing but does anyone know how to capture a variable with a statement. For example, I have a infile that I am trying to reference but it changes daily and I need the program to work without changing the code everyday.

my statement looks like :
infile 'me/you/"the part that changes"|| rest of the file name'

"where the part that changes could be a date"

for some reason its not picking up the part that changes because I created a function and macro variable to capture the correct file daily but I just don't know how to reference it in my infile.

thanks in advance
Super Contributor
Super Contributor
Posts: 3,174

Re: concatenating with filenames

SAS macro variable references must be enclosed in double-quotes, not single-quotes. If you use the latter, then you will get the &whatever_variable instead of the resolved macro variable. So, if you can do a %PUT &whatever_variable; to see your variable just prior to your DATA step, then you need only take care of the double-quote mention above.

Scott Barry
SBBWorks, Inc.
Posts: 0

Re: concatenating with filenames

cannot use assignment expression concatenation (||) in the physical file name of an infile statement.
If the parts are strings, just make it one string.
If some parts are macro variables, enclose all fixed strings and the macro variables in one double quoted(") string.
If any parts are created in a data step variable, then you need to derive a variable holding the concatenated string like[pre] fullName ='me/you/' || variable || 'rest of the file name' ;[/pre] and use the infile option FILEVAR= fullName.
Once you have achieved this concatenation in the relevant way, another infile option FILENAME= {someVarName} will reveal the full path and filename from which the current infile buffer has been loaded.

worth playing around with. For the only example of FILENAME= at, see INFILE example 5 at .

good luck

Ask a Question
Discussion stats
  • 2 replies
  • 2 in conversation