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
Include void in a loopHello, I coded an optimization and I would like to repeat that optimization for subsamples randomly…
Lagged VariablesDear all, in a lot of econometric studies in finance they use lagged variables. Why would they do t…
Migration analysis using "Difference in difference "Dear All, I am looking to the impact of migration on sales. Suppose we have two cities, one receiv…
Position twoway labels in between two ticksHi, What do I have? A twoway graph with a line plot and an area plot. On the x-axis are dates (from…
Problems with Estimation of Translog Cost Function and its derivative - Error Insufficient ObservationDear Statalist members, I am new to Stata and this is my first post. I want to estimate a translog…
Subscribe to:
Post Comments (Atom)
0 Response to converting long to wide - creating a j variable
Post a Comment