Desktop productivity for business analysts and programmers

Dates Between Start and End Date

Accepted Solution Solved
Reply
Contributor
Posts: 29
Accepted Solution

Dates Between Start and End Date

Hi All,

 

I want to find out dates between start date and End Date.

 

suppose 

 

StartDate      EndDate 

01Jan2018   10Jan2018 

 

Then output should be 

Date 

01Jan2018

02Jan2018

03Jan2018

04Jan2018

05Jan2018

06Jan2018

07Jan2018

08Jan2018

09Jan2018

10Jan2018

 


Accepted Solutions
Solution
‎01-11-2018 01:20 AM
Super User
Super User
Posts: 9,227

Re: Dates Between Start and End Date

Posted in reply to ashishj816

Do loops:

data want;
  startdate="01jan2018"d;
  enddate="10jan2018"d;
  do date=startdate to enddate;
    output;
  end;
run;

View solution in original post


All Replies
Solution
‎01-11-2018 01:20 AM
Super User
Super User
Posts: 9,227

Re: Dates Between Start and End Date

Posted in reply to ashishj816

Do loops:

data want;
  startdate="01jan2018"d;
  enddate="10jan2018"d;
  do date=startdate to enddate;
    output;
  end;
run;
Super User
Posts: 13,084

Re: Dates Between Start and End Date

Posted in reply to ashishj816

ashishj816 wrote:

Hi All,

 

I want to find out dates between start date and End Date.

 

suppose 

 

StartDate      EndDate 

01Jan2018   10Jan2018 

 

Then output should be 

Date 

01Jan2018

02Jan2018

03Jan2018

04Jan2018

05Jan2018

06Jan2018

07Jan2018

08Jan2018

09Jan2018

10Jan2018

 


If by "find" you mean that you have an existing data set and want to extract to a new set one way:

data want;
   set have;
   if '01JAN2018'd le datevar le '10JAN2018'd;
run;

If you mean do something for specific records:

 

data want;
   set have;
   if '01JAN2018'd le datevar le '10JAN2018'd do;
     /* statements*/
   end;
run;
☑ This topic is solved.

Need further help from the community? Please ask a new question.

Discussion stats
  • 2 replies
  • 279 views
  • 1 like
  • 3 in conversation