BookmarkSubscribeRSS Feed
skavyasindhu
Fluorite | Level 6

Hi everyone,

I am trying to calculate the number of visits in a 14-day episode. All the visits within 14 days of an index visit count as an episode. The index visit is visit #0. The date is in mmddyy format.

data have - 

ID      date           index       episode_visits      episode_visits_total

1       1/1/2018      1                  0                       .

1       1/2/2018      0                  1                       .

1       1/3/2018      0                  2                       2

1       1/1/2019      1                  0                       .

1       1/18/2019    1                  0                       .

 

My question is, how do I populate the total episode visits when they are 0 (no subsequent visits).

data want - 

ID      date           index       episode_visits      episode_visits_total

1       1/1/2018      1                  0                       .

1       1/2/2018      0                  1                       .

1       1/3/2018      0                  2                       2

1       1/1/2019      1                  0                       0

1       1/18/2019    1                  0                       0

 

Thank you!!

2 REPLIES 2
skavyasindhu
Fluorite | Level 6
 

I am trying to calculate the number of visits in a 14-day episode. All the visits within 14 days of an index visit count as an episode. The index visit is visit #0. The date is in mmddyy format.

data have - 

ID      date           index       episode_visits      episode_visits_total

1       1/1/2018      1                  0                       .

1       1/2/2018      0                  1                       .

1       1/3/2018      0                  2                       2

1       1/1/2019      1                  0                       .

1       1/18/2019    1                  0                       .

 

My question is, how do I populate the total episode visits when they are 0 (no subsequent visits).

data want - 

ID      date           index       episode_visits      episode_visits_total

1       1/1/2018      1                  0                       .

1       1/2/2018      0                  1                       .

1       1/3/2018      0                  2                       2

1       1/1/2019      1                  0                       0

1       1/18/2019    1                  0                       0

 

Thank you!!

ChrisNZ
Tourmaline | Level 20

1. Merged duplicate posts.

- It is rude to do this as you are asking people to work for you while possibly duplicating efforts

- This question does not belong in Data Management

 

2. You goal in unclear. When are zeros added an when not?

sas-innovate-wordmark-2025-midnight.png

Register Today!

Join us for SAS Innovate 2025, our biggest and most exciting global event of the year, in Orlando, FL, from May 6-9. Sign up by March 14 for just $795.


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
  • 2 replies
  • 796 views
  • 0 likes
  • 2 in conversation