DATA Step, Macro, Functions and more

Date in macro

Accepted Solution Solved
Reply
Super Contributor
Posts: 266
Accepted Solution

Date in macro

When using it :

%let bdt = 20050513;

%let nbdt= %sysfunc(inputn(&bdt,yymmdd10.));

%let wbdt=%sysfunc(putn(&nbdt,date9.));

%let npdt=%sysfunc(intnx(month,&nbdt,-1));

%let wpdt=%sysfunc(putn(&npdt,date9.));

%put &bdt &nbdt &wbdt &npdt &wpdt;

Working fine, But use below one creating problem,

%let bdt = 20050513;

%let nbdt= %sysfunc(inputn(&bdt,yymmdd10.));

%let wbdt=%sysfunc(putn(&nbdt,date9.));

%let npdt=%sysfunc(intnx(month,&nbdt,-1,'S')); - Error Point - Using 'S' is creating problem , its a part of intnx function

%let wpdt=%sysfunc(putn(&npdt,date9.));

%put &bdt &nbdt &wbdt &npdt &wpdt;

Can any one please guide me on this .

I want same day for prev month..


Accepted Solutions
Solution
‎03-13-2014 08:39 AM
Super Contributor
Posts: 282

Re: Date in macro

Hi,

Try removing the quotes around the 'S':

%let npdt=%sysfunc(intnx(month,&nbdt,-1,S));

See the documentation on %sysfunc:

SAS(R) 9.4 Macro Language: Reference

Regards,

Amir.

View solution in original post


All Replies
Solution
‎03-13-2014 08:39 AM
Super Contributor
Posts: 282

Re: Date in macro

Hi,

Try removing the quotes around the 'S':

%let npdt=%sysfunc(intnx(month,&nbdt,-1,S));

See the documentation on %sysfunc:

SAS(R) 9.4 Macro Language: Reference

Regards,

Amir.

Super Contributor
Posts: 266

Re: Date in macro

Thanks

🔒 This topic is solved and locked.

Need further help from the community? Please ask a new question.

Discussion stats
  • 2 replies
  • 234 views
  • 0 likes
  • 2 in conversation