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-2024.png

Available on demand!

Missed SAS Innovate Las Vegas? Watch all the action for free! View the keynotes, general sessions and 22 breakouts on demand.

 

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.

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