BookmarkSubscribeRSS Feed
🔒 This topic is solved and locked. Need further help from the community? Please sign in and ask a new question.
BrahmanandaRao
Lapis Lazuli | Level 10

Hi guys Goodmorning,

 

in this data set i want including last date like below 

 

2016-02-29

2017-05-31

2018-06-30

2019-02-28

data dsn;
input date yymmdd10.;
format date yymmdd10.;
datalines;
201602
201705
201806
201902
;
run;

 

1 ACCEPTED SOLUTION

Accepted Solutions
PeterClemmensen
Tourmaline | Level 20

Ok. Do like this then

 

data dsn;
input date;
format date;
datalines;
201602
201705
201806
201902
;
run;

data want;
   set dsn;
   date=intnx('month', input(put(date, 6.), yymmn6.), 0, 'e');
   format date yymmdd10.;
run;

View solution in original post

5 REPLIES 5
PeterClemmensen
Tourmaline | Level 20

Assuming your data is sorted.. Also, I corrected your test data

 

data dsn;
input date :yymmdd10.;
format date yymmdd10.;
datalines;
2016-02-29
2017-05-31
2018-06-30
2019-02-28
;
run;

data want;
   set dsn end=lr;
   if lr;
run;
BrahmanandaRao
Lapis Lazuli | Level 10

Hi Draycut

 

keep it datalines as it is 

201602
201705
201806
201902

but i want output like below

 

2016-02-29

2017-05-31

2018-06-30

2019-02-28

 

andreas_lds
Jade | Level 19

Sorry, but

data dsn;
input date yymmdd10.;
format date yymmdd10.;
datalines;
201602
201705
201806
201902
;
run;

is not working at all, please fix it. As soon as you have a sas-date, you can use intnx to move it to end of the month by using

date = intnx('month', date, 0, 'E');
PeterClemmensen
Tourmaline | Level 20

Ok. Do like this then

 

data dsn;
input date;
format date;
datalines;
201602
201705
201806
201902
;
run;

data want;
   set dsn;
   date=intnx('month', input(put(date, 6.), yymmn6.), 0, 'e');
   format date yymmdd10.;
run;
BrahmanandaRao
Lapis Lazuli | Level 10

Thank you very much

 

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 save with the early bird rate—just $795!

Register now

Mastering the WHERE Clause in PROC SQL

SAS' Charu Shankar shares her PROC SQL expertise by showing you how to master the WHERE clause using real winter weather data.

Find more tutorials on the SAS Users YouTube channel.

Discussion stats
  • 5 replies
  • 1250 views
  • 0 likes
  • 3 in conversation