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
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.
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.