Hi
I'm sure there is probably a simple solution to this but no matter how much I have looked for an answer, I can't find one...
Say I am reshaping from wide to long format, and my particular measurement of interest has potentially 24 values (so in wide format, 24 columns) to represent a monthly measurement over 2 years say. Some individuals do not have measurements at every point, and some finish the measurements early, so there are different 'totals' or number of follow-up points for each individual. When I reshape this to long format, by default, those that do not have a value for months 20 to 24 say, are all missing in the measurement variable but still a row in the dataset. There are also some individuals with missing data earlier in the study period (say missing a value for the 10th month) so their value for that row in the variable is missing as well (but this person continued with the measurements so has values for 11th, 12th etc.).
My question is how can I delete the rows with missing values but only if they had no further measurements?
So for the person who was missing 20-24-> I would like to remove these rows from the dataset, (maybe they had a shorter study period anyway so not really 'missing data') but keep in the individuals who missed the odd measurement but continued recording measurements at a future month?
If I do:
drop if measurement==.
it removes everyone.
Is there a way around this?
Regards
Dan
Related Posts with Removing observations with missing values after reshaping to long format
Looping with both `var' and `i' simultaneouslyHello, I want to loop over my variable list, but also be able to have a number `i' that reflects th…
Clustering standard errors, panel data, when households move to different clusters over timeI have a household panel dataset, with a two stage sample design, first at village and then househol…
Return code of data typeHello, I've noticed the codebook or describe commands don't include datatype in the return code lis…
Adding line to bar graphHi, Is there a way to connect the top of bar graphs in stata like the graph below? I am using the …
Insert empty row by group conditionallyHi, I have a survey data like this: Code: input id sequence q1 q2 q3 q4 q5 001 1 1 3 2 1 5 001 …
Subscribe to:
Post Comments (Atom)
0 Response to Removing observations with missing values after reshaping to long format
Post a Comment