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 2025: Register Now

Registration is now open for SAS Innovate 2025 , our biggest and most exciting global event of the year! Join us in Orlando, FL, May 6-9.
Sign up by Dec. 31 to get the 2024 rate of just $495.
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
  • 812 views
  • 0 likes
  • 3 in conversation