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-2026-white.png



April 27 – 30 | Gaylord Texan | Grapevine, Texas

Registration is open

Walk in ready to learn. Walk out ready to deliver. This is the data and AI conference you can't afford to miss.
Register now and lock in 2025 pricing—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
  • 2 replies
  • 1079 views
  • 0 likes
  • 2 in conversation