DATA Step, Macro, Functions and more

How to create new column should fall between Start_Date and End_Date

Accepted Solution Solved
Reply
Contributor
Posts: 61
Accepted Solution

How to create new column should fall between Start_Date and End_Date

Hi ,I want Worked_Date should fall Between Start_date and End_Dae in new column 

 

Worked_DateStart_DateEnd_Date
27/04/20165/25/20165/25/2016
1/6/20165/26/20165/27/2016
1/7/20165/28/20165/29/2016
1/8/20165/30/20165/31/2016
1/9/20165/31/20166/1/2016
1/10/20166/1/20166/5/2016
1/11/20166/2/20166/6/2016
1/12/20166/6/20166/7/2016
2/5/20166/7/20166/8/2016
2/6/20166/8/20166/9/2016

Accepted Solutions
Solution
‎04-20-2017 10:28 AM
Super User
Super User
Posts: 7,942

Re: How to create new column should fall between Start_Date and End_Date

Posted in reply to sivastat08

Post test data in the form of a datastep!!!

 

As such this is just assuming that those are dates:

data want;
  set have;
  indicator=ifn(start_date <= worked_date <= end_date,1,0);
run;

View solution in original post


All Replies
PROC Star
Posts: 734

Re: How to create new column should fall between Start_Date and End_Date

Posted in reply to sivastat08

I dont understand this question. In none of your records do Worked_Date fall between Start_Date and End_Date? What do you want the new column to contain?

Contributor
Posts: 61

Re: How to create new column should fall between Start_Date and End_Date

 

sorrry for the miscommunication, kind ignore the previous table.

 

Hi i have (Project) start_date and End_Date and Worked_Date   and i want to create indicateor for Worked_Date weather correctly falling between Start_Date and End_Date .

 

 

ProjectStartDateEndDateWorked_Date
15/25/20164/9/20171/1/2017
24/10/201712/31/21992/7/2017
35/25/201612/31/21993/9/2017
45/25/201612/31/21994/11/2017
55/25/201612/15/201612/10/2016
612/16/201612/31/21993/13/2017
75/25/20162/19/20171/12/2017
85/25/201612/31/21994/7/2017
Super User
Posts: 5,424

Re: How to create new column should fall between Start_Date and End_Date

Posted in reply to sivastat08

Well, just see of if work date date falls between start and end dates, and assign a indicator value of the comparison result. What part is it you don't know how to do? What have you tried so far?

Data never sleeps
Contributor
Posts: 61

Re: How to create new column should fall between Start_Date and End_Date

Thanks for your motivation LinusH..going forward i will try to do.
Solution
‎04-20-2017 10:28 AM
Super User
Super User
Posts: 7,942

Re: How to create new column should fall between Start_Date and End_Date

Posted in reply to sivastat08

Post test data in the form of a datastep!!!

 

As such this is just assuming that those are dates:

data want;
  set have;
  indicator=ifn(start_date <= worked_date <= end_date,1,0);
run;
Contributor
Posts: 61

Re: How to create new column should fall between Start_Date and End_Date

Thanks for the answer RW9.

☑ This topic is solved.

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

Discussion stats
  • 6 replies
  • 125 views
  • 4 likes
  • 4 in conversation