BookmarkSubscribeRSS Feed
msf2021
Fluorite | Level 6

Hi everyone!

I have a dataset with policies date began between 2018-01-01 and 2019-12-31 (2 years) that has the following info:

policy          policy_beg_date	   policy_end_date
a	           01-02-2018	    06-02-2018
b	           04-02-2019	    02-04-2020
c	           23-12-2019	    03-02-2020
d	           02-02-2019	

policy begining date (date that policy started) and policy end date (date that policy ended - is missing if policy is still active)

 

I would like to create flags of 13 months (flag_0month, flag_1month,....flag_13month) where i give 1 if policy is active in month 0, month1, and so on....where month0 is the month of beginnig, month1 is month of begining + 1 and so on so i would have something like this:

 

policy          policy_beg_date	   policy_end_date	month_begining	 month_end	act_month0	act_month1	act_month2
a	            01-01-2018	      06-01-2018	   201801	   201801	   1		
b	            04-02-2019	      02-04-2020	   201902	   202003	   1	             1	            1
c	            23-12-2019	      03-02-2020	   201912	   202002	   1	             1	            1
d	            02-02-2019		                   201902		           1	             1         	    1

Can anyone please help me achivieng this?

I already tryied someting like in this post : https://communities.sas.com/t5/SAS-Programming/How-to-create-a-flag-for-each-month-lying-between-2-d... but i get errors and i think it's not the same as i need.

 

Thank you!!

 

1 REPLY 1
Kurt_Bremser
Super User

So you want to check for only 13 months, even if the policy runs for a longer term?

How many months should be checked if the end date is missing and 13 months from the start date would be in the future?

Ready to join fellow brilliant minds for the SAS Hackathon?

Build your skills. Make connections. Enjoy creative freedom. Maybe change the world. Registration is now open through August 30th. Visit the SAS Hackathon homepage.

Register today!
How to Concatenate Values

Learn how use the CAT functions in SAS to join values from multiple variables into a single value.

Find more tutorials on the SAS Users YouTube channel.

Click image to register for webinarClick image to register for webinar

Classroom Training Available!

Select SAS Training centers are offering in-person courses. View upcoming courses for:

View all other training opportunities.

Discussion stats
  • 1 reply
  • 465 views
  • 0 likes
  • 2 in conversation