DATA Step, Macro, Functions and more

Inserting the value of a date variable into a filename during proc export

Reply
New Contributor
Posts: 2

Inserting the value of a date variable into a filename during proc export

I'm trying to include the value of two prompts I have generated in SAS EG in the filename during a PROC EXPORT step.  One prompt is numeric and resolves in the file name just fine, but the other prompt is a date and I keep getting WARNING: Apparent symbolic reference LOOKBACKSTARTDATE not resolved.

 

My code:

PROC Export DATA=WORK.MONTHLYCOMPILED
OUTFILE="C:\Documents\SASoutput\monthly_&lookbackstartdate._&txstartcohort..csv"
DBMS=csv
REPLACE;
RUN;

 

The date variable - &loobackstartdate - describes the start date for the data set that went into the anlaysis.  It's not like a date/time stamp for the run itself, so using a function that inserts today's date is not what I'm going for.  

 

I played around with trying to convert &lookbackstartdate into text and saving that as another variable with a preceding %let step, but I'm just tripping over myself on how to do that.

Super User
Super User
Posts: 7,413

Re: Inserting the value of a date variable into a filename during proc export

So where is &lookbackstartdate. defined?  The warning is telling you that there is no macro variable by that name in the current scope.  Not sure how we could help you further without some information?

New Contributor
Posts: 2

Re: Inserting the value of a date variable into a filename during proc export

It's defined via a prompt I created in SAS EG, and set to be used throughout the project.  It is used in other queries in the project to restrict data.  It's the same thing I have done for the numeric txstartcohort variable that does resolve correctly.

 

 Edit Prompt_2017-08-01_10-55-03.jpg

Super User
Posts: 10,538

Re: Inserting the value of a date variable into a filename during proc export


weissalberich wrote:

It's defined via a prompt I created in SAS EG, and set to be used throughout the project.  It is used in other queries in the project to restrict data.  It's the same thing I have done for the numeric txstartcohort variable that does resolve correctly.

 

 Edit Prompt_2017-08-01_10-55-03.jpg


You don't show the name used in the construction. I would triple check spelling for your use &LOOKBACKSTARTDATE. Perhaps the entry screen cutoff a few characters or you accidentaly used LOOKBACKSTARTDATA or similar

Super User
Posts: 17,912

Re: Inserting the value of a date variable into a filename during proc export

What happens then that's unexpected, your code looks correct.

Ask a Question
Discussion stats
  • 4 replies
  • 88 views
  • 0 likes
  • 4 in conversation