BookmarkSubscribeRSS Feed
deleted_user
Not applicable
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
2 REPLIES 2
sbb
Lapis Lazuli | Level 10 sbb
Lapis Lazuli | Level 10
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.
deleted_user
Not applicable
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 support.sas.com, see INFILE example 5 at http://support.sas.com/documentation/cdl/en/lrdict/61724/HTML/default/a000146932.htm#a000177201 .

good luck

PeterC

sas-innovate-2024.png

Don't miss out on SAS Innovate - Register now for the FREE Livestream!

Can't make it to Vegas? No problem! Watch our general sessions LIVE or on-demand starting April 17th. Hear from SAS execs, best-selling author Adam Grant, Hot Ones host Sean Evans, top tech journalist Kara Swisher, AI expert Cassie Kozyrkov, and the mind-blowing dance crew iLuminate! Plus, get access to over 20 breakout sessions.

 

Register now!

What is Bayesian Analysis?

Learn the difference between classical and Bayesian statistical approaches and see a few PROC examples to perform Bayesian analysis in this video.

Find more tutorials on the SAS Users YouTube channel.

Click image to register for webinarClick image to register for webinar

Classroom Training Available!

Select SAS Training centers are offering in-person courses. View upcoming courses for:

View all other training opportunities.

Discussion stats
  • 2 replies
  • 4847 views
  • 0 likes
  • 2 in conversation