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
Creating a variable that counts the number of respondents in different ethnic groups per yearGreetings, I'm running Stata 15.1 and working with data from the American Community Survey. My goal…
"record too long" in Stata16 MPI was dealing with a dataset (about 50 thousand variables and unknown observations) download from So…
Looping over folders with putexcel to modify state-specific tables in state-specific foldersHello, I am writing a .do file to create 20 tables for each U.S. state using data on state agencies…
Small sample mixed methods with varying degrees of freedom and lincomHi Stata experts! I have a situation that I've been unable to Google my way to a resolution. I hav…
Cannot get ipdfc to workI happened to come across a user written program which might be the solution to what I am attempting…
Subscribe to:
Post Comments (Atom)
0 Response to Removing observations with missing values after reshaping to long format
Post a Comment