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

data wt;
datenew=intnx('qtr','01jan94'd,1,'middle');
format datenew mmddyy10.;
run;

 

its output is coming as 05/16/1994 but qarter consists of 3 months so it should be 04/16/1994.

Please help me with this.

 

1 ACCEPTED SOLUTION

Accepted Solutions
Kurt_Bremser
Super User

@s_m wrote:

data wt;
datenew=intnx('qtr','01jan94'd,1,'middle');
format datenew mmddyy10.;
run;

 

its output is coming as 05/16/1994 but qarter consists of 3 months so it should be 04/16/1994.

Please help me with this.

 


Why? The middle of the second quarter (months 4, 5 and 6) is the middle of month 5.

View solution in original post

3 REPLIES 3
Kurt_Bremser
Super User

@s_m wrote:

data wt;
datenew=intnx('qtr','01jan94'd,1,'middle');
format datenew mmddyy10.;
run;

 

its output is coming as 05/16/1994 but qarter consists of 3 months so it should be 04/16/1994.

Please help me with this.

 


Why? The middle of the second quarter (months 4, 5 and 6) is the middle of month 5.

Reeza
Super User

If you want 3 months from the date use MONTH and 3 instead of QTR. Also note that April has 30 days so it would be the 15th NOT the 16th.  See the code and output below.

 

60 data wt;
61 date1=intnx('qtr','01jan94'd,1,'m');
62 date2=intnx('MONTH','01jan94'd,3,'m');
63 format date: mmddyy10.;
64
65 put "QTR = " date1;
66 put "Month = " date2;
67 run;
 
QTR = 05/16/1994
Month = 04/15/1994
NOTE: The data set WORK.WT has 1 observations and 2 variables.
NOTE: DATA statement used (Total process time):
real time 0.00 seconds
cpu time 0.01 seconds

 

 

 

 

Tom
Super User Tom
Super User

You need to tell it that is what you want.

data test1;
  date = '01JAN1994'd ;
  next_qtr = intnx('qtr','01jan94'd,1,'middle');
  first_month_of_next_qtr = intnx('month',intnx('qtr','01jan94'd,1,'s'),0,'middle');
  format _all_ yymmdd10.;
  put (_all_) (=/);
run;

date=1994-01-01
next_qtr=1994-05-16
first_month_of_next_qtr=1994-04-15

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
  • 3 replies
  • 1587 views
  • 5 likes
  • 4 in conversation