I am extremely new to SAS, and know nothing of coding!! I am attempting to add a date, in MMMYYYY format, to my exported filename based on the previous month. For example, If I am reporiting data as of the end of February, and it is currently March. What would I need to write in my %let statement?
I have tried
%let reptgmo = %sysfunc(today()-31,AFRDFMYw.);
It says I am missing a parenthesis after macro function, but as far as I can see, I have matching parens. Is there a better way to do this for set it and forget it reporting.
Thanks in advance!
Hello @EIrvin,
Here's a corrected version of your %LET statement:
%let reptgmo=%sysfunc(intnx(month,%sysfunc(today()),-1),AFRDFMY7.);
Macro (%let in your case) is a text focused language. You can force calculation by using %eval(). But it quickly becomes quite unreadable. So sometimes it's easier to do you calculation in a data _null_; step, and then do a call symput() to generate your macro variable.
But if you are new to SA coding, perhaps you should try to use a Prompt instead, which in turn will generate the macro variable for you.
Hello @EIrvin,
Here's a corrected version of your %LET statement:
%let reptgmo=%sysfunc(intnx(month,%sysfunc(today()),-1),AFRDFMY7.);
Freelance,
Thank you so much, that explained a lot!
E
Available on demand!
Missed SAS Innovate Las Vegas? Watch all the action for free! View the keynotes, general sessions and 22 breakouts on demand.
What’s the difference between SAS Enterprise Guide and SAS Studio? How are they similar? Just ask SAS’ Danny Modlin.
Find more tutorials on the SAS Users YouTube channel.