BookmarkSubscribeRSS Feed
SAS_user122
Calcite | Level 5

Hi! I have a dataset that looks like this:

 

patient_id start_date     end_date

123           01Jan2016   15Apr2020

321           09Sep2018   17Nov2019

567            07Jul2017    09Jul2020

567            09Sep2020   10Dec2020

 

My study period is 01Jan2016-31Dec2020. I want to create a new variable called time that creates a flag if someone's study period included that particular month (ex. 1=Jan2016, 2=Feb2016, etc). So my data set would end up looking like this:

patient_id start_date     end_date      time

123           01Jan2016   15Apr2020    1

123           01Jan2016   15Apr2020    2

123           01Jan2016   15Apr2020    3

123           01Jan2016   15Apr2020    4

etc

 

Any thoughts on how to do this?

1 REPLY 1
PaigeMiller
Diamond | Level 26

So what is the expected output for patient_id 321 and patient_id 567?

 

Is the first month always January 2016, or does it vary by patient_id?


What is the last month to use?

--
Paige Miller

SAS Innovate 2025: Register Now

Registration is now open for SAS Innovate 2025 , our biggest and most exciting global event of the year! Join us in Orlando, FL, May 6-9.
Sign up by Dec. 31 to get the 2024 rate of just $495.
Register now!

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.

SAS Training: Just a Click Away

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

Browse our catalog!

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