Desktop productivity for business analysts and programmers

Macro From Manual to Automated?

Occasional Contributor
Posts: 5

Macro From Manual to Automated?

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?






Super User
Super User
Posts: 9,799

Re: Macro From Manual to Automated?

Posted in reply to Scottie_T

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()))));


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.


Ask a Question
Discussion stats
  • 1 reply
  • 2 in conversation