BookmarkSubscribeRSS Feed
🔒 This topic is solved and locked. Need further help from the community? Please sign in and ask a new question.
ashishj816
Quartz | Level 8

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

 

1 ACCEPTED SOLUTION

Accepted Solutions
RW9
Diamond | Level 26 RW9
Diamond | Level 26

Do loops:

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

View solution in original post

2 REPLIES 2
RW9
Diamond | Level 26 RW9
Diamond | Level 26

Do loops:

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

@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;

hackathon24-white-horiz.png

2025 SAS Hackathon: There is still time!

Good news: We've extended SAS Hackathon registration until Sept. 12, so you still have time to be part of our biggest event yet – our five-year anniversary!

Register Now

Creating Custom Steps in SAS Studio

Check out this tutorial series to learn how to build your own steps in SAS Studio.

Find more tutorials on the SAS Users YouTube channel.

SAS Training: Just a Click Away

 Ready to level-up your skills? Choose your own adventure.

Browse our catalog!

Discussion stats
  • 2 replies
  • 4542 views
  • 3 likes
  • 3 in conversation