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;

SAS Innovate 2025: Save the Date

 SAS Innovate 2025 is scheduled for May 6-9 in Orlando, FL. Sign up to be first to learn about the agenda and registration!

Save the date!

SAS Enterprise Guide vs. SAS Studio

What’s the difference between SAS Enterprise Guide and SAS Studio? How are they similar? Just ask SAS’ Danny Modlin.

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
  • 4163 views
  • 3 likes
  • 3 in conversation