BookmarkSubscribeRSS Feed
deleted_user
Not applicable
Hello, I'm trying to create macros containing the first date of the month for all months in between certain dates (in the case below, it is a calendar year, but this will not be the case every time).
The bold part of the program (macro dates_month)is not working for me; I'm not sure why. I'm not concerned with the actual values at this point, I'm just trying to figure out why macros &Date1 - $Date12 are not being created.
Thanks,
Joe

%macro date_calc;

data _null_;
Start = put(intnx('month',today(),-14),date9.);
call symput('Start',"'"||Start||"'d");
run;

data _null_;
firstday = intnx('month',today(),-2);
End = put((firstday - 1),date9.);
call symput('End',"'"||End||"'d");
run;

%mend date_calc;
%date_calc;

data _null_;
MONTH= INTCK('MONTH',&start,&End+1);
call symput('MONTH',(Month));
run;

%put(Start) = &Start;
%put(End) = &End;
%put(Month) = &Month;


%macro dates_month;
%do I = 1 %to 12;
data _null_;
Date&I = intnx('month',&Start,&I);
call symput("Date&I",Date&I);
run;
%end;
%mend;
%dates_month;

%put(Date1) = &Date1;
1 REPLY 1
deleted_user
Not applicable
I see you've had a number of very detailed replies on this problem through SAS/L.

I presume these will help you resolve your problem.

Kind regards

David

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!

How to Concatenate Values

Learn how use the CAT functions in SAS to join values from multiple variables into a single value.

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
  • 551 views
  • 0 likes
  • 1 in conversation