BookmarkSubscribeRSS Feed
Scottie_T
Calcite | Level 5

I have the following macro that allows me to pull all information for the most recent months into my analysis.

 

%let calyear = 2016;
%let month = 10;
%let YYYYMM = 201610;

I have to change the month, year, & calyear as needed.

 

Let's say I wanted to schedule this proces to run on the 15th of every month and it would always pull the previous month?

I have four process flows that link to these variables and pull the data.

 

Does anyone have any tips on this?

 

Thanks

Scottie 

 

 

1 REPLY 1
RW9
Diamond | Level 26 RW9
Diamond | Level 26

Well, I know nobody really uses base SAS any more (/sarcasm).  It has lots of functions for date manipulations, data structures associated with dates, your code looks like:

data _null_;
  call symputx("CALYEAR",year(datepart(today())));
  call symput("MONTH",month(datepart(today())));
  call symput("YYYYMM",cats(year(datepart(today())),month(datepart(today()))));
run;

%put &CALYEAR., &MONTH., &YYYYMM.;

The above creates your macro variables base on the date of run.  I would of course advise that there are better ways to do this, use datasets for your parameters etc.  Macro language is text only and doesn't do anything other than create text strings.

 

sas-innovate-2024.png

Join us for SAS Innovate April 16-19 at the Aria in Las Vegas. Bring the team and save big with our group pricing for a limited time only.

Pre-conference courses and tutorials are filling up fast and are always a sellout. Register today to reserve your seat.

 

Register now!

SAS Enterprise Guide vs. SAS Studio

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.

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
  • 1 reply
  • 661 views
  • 0 likes
  • 2 in conversation