I’m doing analysis on a longitudinal study with up to 10 visits for some participants. Some data are missing. If data for a participant are not missing at a subsequent visit, then that subsequent visit data needs to replace the prior missing data. For example, participant A might have missed visit 1 but attended visits 2 through 10. I need the nonmissing data in vists 2-10 to concatenate left (or ‘shift’ to the left) so there are nonmissing data in vists 1-9 and one missing datum in visit 10. Of course, missing data could occur at any visit. All variable names have a suffix identifying visit number. Below is an example using numeric data (for example, positive or negative blood tests at each of ten visits); however, variables could be character or numeric. All help on this is appreciated - I wonder now if converting this wide data to long form is the first step... Data Have Obs x_v1 x_v2 x_v3 x_v4 x_v5 x_v6 x_v7 x_v8 x_v9 x_v10 1 . 1 0 1 0 1 0 1 0 1 2 0 . 1 0 0 . . 1 0 0 3 . 1 0 1 0 1 0 1 0 . Data Want Obs x_v1 x_v2 x_v3 x_v4 x_v5 x_v6 x_v7 x_v8 x_v9 x_v10 1 1 0 1 0 1 0 1 0 1 . 2 0 1 0 0 1 0 0 . . . 3 1 0 1 0 1 0 1 0 . .
... View more