0

I have a dataset, where I want to group 2 columns together (Proc Right and Days to Proc Right) and separate it from the next group of 2 columns (Proc Left and Days to Proc Left). During separation, I want to separate based on chronology of days to procedure, and assign 0 and NA to the other 2 columns which chronologically are later. I then want to create a new column pulling only the days to procedure.

To summarise:

Have this:

ID Proc ID Proc Right Days to Proc Right Proc Left Days to Proc Left
1 108 4 41 4 168
1 105 4 169 4 42
1 101 3 270 0 NA

Want this:

ID Proc ID Proc Right Days to Proc Right Proc Left Days to Proc Left Days to Proc
1 108 4 41 0 NA 41
1 108 0 NA 4 168 168
1 105 0 NA 4 42 42
1 105 4 169 0 NA 169
1 101 3 270 0 NA 270

Would appreciate any help. Thanks

I have tried unite and cSplit, which separates the column groups, but doesn't help me assign 0 and NA to the other columns.

0 Answers0