Hello everyone. Thanks for looking at my post. I hope you can help a PhD candidate...
I have a data set with 170 subjects, each of whom have daily repeated measures for up to 7 days, in addition to many one-time measures like demographics, baseline characteristics, and outcomes. My data is in long form and each subject has a different number of rows. In long shape it is 1800 rows and there are about 100 columns. I need to convert the whole thing to wide format to work on a mixed effects logistic regression model. I didn't have a good "j" variable for the "reshape wide" command. I tried creating one which I called j1 with [by record_id: generate j1 = _n] which appears to give me a unique variable within each subject, but when I tried [reshape wide age race ethnicity ... [ 100 variables], i(record_id) j(j1)]. I got the command to run and my data is reshaped to (really)wide, but those measures which should only occur once (e.g., age, BMI, mortality) now are duplicated 19 times (i.e., age1, age2, ..., age19). when I tried to reshape with only the daily repeating measures, the command won't run and I get "variable variablename not constant within record_id." I could go through air drop almost 2,000 useless variables, but is there a more eloquent way?
I'm using Stata/IC 14.2 running in a Microsoft remote desktop on a mac. I hope this post was both precise enough and concise enough.
Thank You,
Tom Lawson
Related Posts with converting long to wide - creating a j variable
Significant time dummiesHello! I am doing research on corruption and have a balanced panel data set of 363 observations for…
Counting observations from a multivariate logistic regressionHello, I wish to know how I can determine the number of observations for an outcome variable (case …
ppml with high fixed effectsHi, everyone! I am an undergraduate student who is researching for his thesis about international tr…
Correcting and consolidating multiple name spellingsI am currently working on a dataset of government contracts and have run into an issue while cleanin…
Why do I have a base outcome (reference outcome with zero coefficients)?Dear Professionals, I am working on developing transport mode choice models, I used Multinomial Log…
Subscribe to:
Post Comments (Atom)
0 Response to converting long to wide - creating a j variable
Post a Comment