user14208300
user14208300

Reputation: 35

SAS - Create an incremental table

I need to create an incremental table in SAS. This table contains the first day of month and the final month day until today (every month needs to execute).It seems like this

First day month Final month day
01/01/2019  31/01/2019
01/02/2019  28/02/2019
01/03/2019  31/03/2019
01/04/2019  30/04/2019
01/05/2019  31/05/2019
01/06/2019  30/06/2019
01/07/2019  31/07/2019
01/08/2019  31/08/2019
01/09/2019  30/09/2019
01/10/2019  31/10/2019
01/11/2019  30/11/2019
01/12/2019  31/12/2019
01/01/2020  31/01/2020
01/02/2020  29/02/2020
01/03/2020  31/03/2020
01/04/2020  30/04/2020
01/05/2020  31/05/2020
01/06/2020  30/06/2020
01/07/2020  31/07/2020
01/08/2020  31/08/2020
01/09/2020  30/09/2020
01/10/2020  31/10/2020

Thanks

Upvotes: 2

Views: 78

Answers (1)

PeterClemmensen
PeterClemmensen

Reputation: 4937

Try this

data want;
   first = '01jan2019'd;
   do while (1);
      last = intnx('month', first, 0, 'e');
      if last > today() then leave;
      output;
      first = last + 1;
   end;
   format first last ddmmyy10.;
run;

Upvotes: 2

Related Questions