BookmarkSubscribeRSS Feed
🔒 This topic is solved and locked. Need further help from the community? Please sign in and ask a new question.
sayanapex06
Obsidian | Level 7

Hi

I have a requirement to check : first date of the current month  & last month's first date +1

 

So today's date is : 2/12/2018

 

I want the first range as : 02/01/2018 ( 2nd jan 2018)

                 second range : 01/02/2018 (1st of feb 2018)

 

I have tried :

 

%LET PRE_MO = %SYSFUNC(INTNX(MONTH, %SYSFUNC(&CURR), -1),DATE9.) ;

 

I am getting PRE_MO  AS  : 01JAN2018  , but I want it be increased by 1

I am trying : R = INTNX(('MONTH',AEENDTC1,0,"BEGINNING")),DATE9. ;    ( to get the first day of this month)

 

But error shows : 

R = INTNX(('MONTH',AEENDTC1,0,"BEGINNING")),DATE9. ;
_ _
_ _
_ _
79 22
79 22
79 22
_
_
_
200
200
200
: Expecting a ).

 

 

1 ACCEPTED SOLUTION

Accepted Solutions
PeterClemmensen
Tourmaline | Level 20

LIke this?

 

data test;
	today="12feb2018"d;
	first=intnx("month", today, -1, "b")+1;
	second=intnx("month", today, 0, "b");

	format today first second date9.;
run;

View solution in original post

2 REPLIES 2
PaigeMiller
Diamond | Level 26
%LET PRE_MO = %eval(%SYSFUNC(INTNX(MONTH, &CURR, -1,b))+1) ;

%put %sysfunc(putn(&pre_mo,date9.));

Work with dates (and date-time values) as numbers rather than formatted values whenever possible.

 

Use the formatted values only when absolutely necessary, for example when displaying results for human eyes.

 

 

--
Paige Miller
PeterClemmensen
Tourmaline | Level 20

LIke this?

 

data test;
	today="12feb2018"d;
	first=intnx("month", today, -1, "b")+1;
	second=intnx("month", today, 0, "b");

	format today first second date9.;
run;

sas-innovate-2026-white.png



April 27 – 30 | Gaylord Texan | Grapevine, Texas

Registration is open

Walk in ready to learn. Walk out ready to deliver. This is the data and AI conference you can't afford to miss.
Register now and lock in 2025 pricing—just $495!

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.

SAS Training: Just a Click Away

 Ready to level-up your skills? Choose your own adventure.

Browse our catalog!

Discussion stats
  • 2 replies
  • 6870 views
  • 5 likes
  • 3 in conversation