Hi all,
First Statalist post and beginner on Stata so thank you for your patience!
I am trying to create a single Excel worksheet which will have one row for every error in our dataset. I'm using Stata version 14.2. I have already created the code to identify errors - probably not the smoothest way, but for each variable (e.g. height), I created a new variable (e.g. heightx) whose value is 1 if an error in that variable is detected. My dataset consists of 3,900 observations, each of which represents a form completed by a participant. (About 2,000 participants have completed anywhere between 1-6 forms). The 2,000 participants are identified by an id variable (rid) and the forms have their own variable (form).
In my example, if the value of heightx = 1 for a given form, I would like to export 4 characteristics (id, facility, visit date and form number) taken from the row this is true from. I've used mkmat to create a matrix of these values, and putexcel to export the results to an Excel worksheet. However, I have hundreds of variables I'll be checking for errors on. Rather than have to export the matrix results each time manually, I was hoping to create a loop (I think using foreach?) and have all the matrix results export at once - stacking vertically within a single Excel worksheet. However, since the number of errors identified in a given variable will constantly be changing (one week there might be 5 errors in heightx, another week 155), I can't predict what row/cell number the second, third and subsequent matrix results will export to.
Is there a way to tell Stata: "export the results of the heightx matrix to Excel and put those in cell A2, and then export the results of the weightx matrix to that same worksheet, beginning at the next blank row"? I did see this post but wasn't quite sure if it's the same thing I'm trying to do...
Thanks for your help,
~Cristina
Related Posts with Stacking results from multiple matrices using putexcel
Set of error termsIf I want to create a set of error terms in a dataset. Can I just use the variable gen error = rnorm…
How can I Make these code to loop code ?Hi. I want to make loop code of below. Code: gen A01_GLU0_new =. replace A01_GLU0_new = A01_GLU0_…
Aggregating variablesGood day everyone, I am still an undergrad student so please excuse any elementary questions. I am…
Plot confidence interval for linear mixed modelHi, I'm running a linear mixed model, and am now trying to plot a fitted line with a 95% CI for thi…
Controlling for confounders in t-testsHi all, I'm a little stuck on a paper looking at differences in fasting glucose levels between diff…
Subscribe to:
Post Comments (Atom)
0 Response to Stacking results from multiple matrices using putexcel
Post a Comment