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
Postfile only posts results of first iteration of the loopDear statalist, I have a big file that overwhelms my memory when I try to run my script. Therefore,…
Meta-analysis Ipdmetan (ssc) versus meta forestplotHi, I am doing meta-analysis for individual patient data. I get different overall results when I us…
How to Conduct the Pre and Post Analysis?Dear all, I have panel data from 2015 to 2019, i want to check pre period 2015 and 2016 descriptive …
How to Conduct the Pre and Post Analysis?Dear all, I have panel data from 2015 to 2019, i want to check pre period 2015 and 2016 descriptive …
Quantile regression with pweights, cluster standard errors and strata fixed effectsHi! I need to run a cross-sectional quantile regression with pweights, strata fixed effects and clus…
Subscribe to:
Post Comments (Atom)
0 Response to Stacking results from multiple matrices using putexcel
Post a Comment