DATA Step, Macro, Functions and more

Creating dataset with ultimo month dates

Reply
Occasional Contributor
Posts: 5

Creating dataset with ultimo month dates

Hi

 

I need a program that forms at the end of month dates between two dates.

 

Somthing like:

 

data date;

format date ddmmyy10.;

do date='01jan2010'd to '31dec2016'd by 1;

output;

end;

run;

 

But unly with one date for each month.

 

data months;

format date ddmmyy10.;

do date=intnx('month', '31dec2010'd, n)-1 to '31dec2016'd  by n;

output;

end;

run;

 

But how to I count n up with 1 to 31dec2016?

 

Best regards

Terkel

 

Super User
Posts: 5,438

Re: Creating dataset with ultimo month dates

Do a regular do loop with a plain increment variable. Here you specify how many months you wish to generate.

Use that in your assignment statement as an argument in the intnx() function.

Data never sleeps
Super User
Posts: 10,044

Re: Creating dataset with ultimo month dates

data date;
format date ddmmyy10.;
do date='01jan2010'd to '31dec2016'd by 1;
 if day(date+1)=1 then output;
end;
run;
Ask a Question
Discussion stats
  • 2 replies
  • 250 views
  • 0 likes
  • 3 in conversation