Hey all,
In advance would like to say sorry for experienced users for asking this (just cannot find the answer). I have a dataset which is Millenium cohort study (MSC6). Physical Activity (PA) is recorded for 2 days (weekday and weekend), hence two rows for each ID variable, so the question is what is the best way to handle such data? I have reshaped it to wide (it was originally in long format) and made 2 variables instead of 1. So, now I have a set of variables for day 1 and set for day 2, however there are lot of missing values and I simply cannot drop them as the whole row drops. (Picture attached). This accelerometer data: MCID - Id variable; FCACCAD - day accelerometer was assigned. Apologies if this is not really clear and any help would be highly appreciated.
[CODE]
gen day2 = 2 if (FCACCAD==2)
replace day2 = 1 if (FCACCAD ==1)
gen day1 =1 if (FCACCAD ==1)
replace day1=2 if (FCACCAD ==2)
gen MCSPID = _n
reshape wide MCSID FCACCWEEKDAY FCACC_N_VALID_HRS FCACC_MEAN_ACC_24H FCACC_MVPA_MEAN_ACC_E1MIN_100MG FCACC_MVPA_E5S_B1M80_T100_ENMO, i(MCSPID) j(FCACCAD)
clonevar fca1 = FCACCWEEKDAY1
clonevar fca2 = FCACCWEEKDAY2
clonevar valid_hrs1 = FCACC_N_VALID_HRS1
clonevar valid_hrs2 = FCACC_N_VALID_HRS2
clonevar mean1 = FCACC_MEAN_ACC_24H1
clonevar mean2 = FCACC_MEAN_ACC_24H2
clonevar mvpa_mean1 = FCACC_MVPA_MEAN_ACC_E1MIN_100MG1
clonevar mvpa_mean2 = FCACC_MVPA_MEAN_ACC_E1MIN_100MG2
clonevar mvpa801 = FCACC_MVPA_E5S_B1M80_T100_ENMO1
clonevar mvpa802 = FCACC_MVPA_E5S_B1M80_T100_ENMO2
[CODE]
Related Posts with Two ID variables for each row
Graph editingHello Statalist! I am using the graph below as part of my exploratory data analysis in a cross-sect…
survey data analysisI am new to STATA (15.1) and hope someone can help me with how to "Declare my survey design for my d…
Confusing Decomposition output for the explained component using oaxaca and mvdcmpGood day, I am using decomposing analysis to run the following command on individual level data in …
Macro regression with survey contextHello, I want to run a regression and subsequent prediction separately for 23 independent variables…
Interpretation of Regression ResultsHello esteemed members of Statalist! I am conducting a cross-sectional analysis of UK firms examini…
Subscribe to:
Post Comments (Atom)
0 Response to Two ID variables for each row
Post a Comment