Haveing this
subjid visitnum day visit
0076 1 1 V1 Day 1_Baseline
0076 2 28 V2 Day 28
0076 3 56 V3 Day 56
0076 4 84 V4 Day 84_EOT_ET
0088 1 1 V1 Day 1_Baseline
0088 3 28 V2 Day 28
0088 . . .
0088 5 56 V4 Day 84_EOT_ET
0099 1 1 V1 Day 1_Baseline
0099 3 28 V2 Day 28
0099 . . .
0099 5 58 V4 Day 84_EOT_ET
0758 1 1 V1 Day 1_Baseline
0758 3 30 V2 Day 28
0758 . . .
0758 5 57 V4 Day 84_EOT_ET
0169 1 1 V1 Day 1_Baseline
0169 3 30 V2 Day 28
0169 5 37 V4 Day 84_EOT_ET
I want this one :
subjid visitnum day visit avisit avisitnum type
0076 1 1 V1 Day 1_Baseline Visit 1/ Baseline 1
0076 2 28 V2 Day 28 Visit 2/Week 4/Day 28 2
0076 3 56 V3 Day 56 Visit 3/Week 8/Day 56 3
0076 4 84 V4 Day 84_EOT_ET Visit 4/Week 12/Day 84 4
0088 1 1 V1 Day 1_Baseline Visit 1/ Baseline 1
0088 3 28 V2 Day 28 Visit 2/Week 4/Day 28 2
0088 5 56 V4 Day 84_EOT_ET Visit 3/Week 8/Day 56 3
0088 . . . Visit 4/Week 12/Day 84 4 locf
0099 1 1 V1 Day 1_Baseline Visit 1/ Baseline 1
0099 3 28 V2 Day 28 Visit 2/Week 4/Day 28 2
0099 5 58 V4 Day 84_EOT_ET Visit 3/Week 8/Day 56 3
0099 . . . Visit 4/Week 12/Day 84 4 locf
0169 1 1 V1 Day 1_Baseline V1 Day 1_Baseline 1
0169 3 30 V2 Day 28 Visit 2/Week 4/Day 28 2
0169 5 37 V4 Day 84_EOT_ET Visit 2/Week 4/Day 28 2
0169 . . . Visit 3/Week 8/Day 56 3 locf
0169 . . . Visit 4/Week 12/Day 84 4 locf
Yep, you going to pay me to type all that in, then code it for you? Seems to be a very simple select(visit) to decode avisit and avisitnum. As for locf simply create a template for how many visits and merge that on, something like:
data temp; avisitnum=1; avisit="..."; output; ... run; data want; merge have (in=a) temp (in=b); by avisitnum avisit; if b and not(a) then type="locf"; run;
Join us for SAS Innovate April 16-19 at the Aria in Las Vegas. Bring the team and save big with our group pricing for a limited time only.
Pre-conference courses and tutorials are filling up fast and are always a sellout. Register today to reserve your seat.
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.