asdocx: Export from Stata to Word, Excel, LaTeX & HTML › Forums › asdocx Forum › bysort and if don’t get along
-
AuthorPosts
-
Hi Dr. Shah,
I am trying the following commands:
bysort A: asdocx tab X Y if Z == 1, chi2 col
In this case, only the first table is output. In other words, if A is 1,2,3, only the result for A=1 will be output; the same is true for Stata’s result display window.
If there is no if statement, it works fine.
In my opinion, the combination of bysort and if is causing the error.I was going to post this on the forum, but I don’t know my account, so I contacted you here.
We would appreciate your response.
Sincerely
Hi Dr. Shah — this is true for me too, but when using list and tabdisp. Any help would be appreciated!
– Kevin
I have fixed the issue reported by Keiji Muramatsu. This will hopefully also fix the other issues reported by Kevin. If the update does not solve the other issues, Kevin may like to post an example.
asdocx_update webuse citytemp2, clear gen group=mod(_n, 3) asdocx tab region agecat if tempjan >22, by(group) replace Tabulation of region agecat : group = 0 0 |1 2 3 4 5 ----+----------------------------------------------------------------------------- 1 | Census Region agecat 2 | 19-29 30-34 35+ Total ----+----------------------------------------------------------------------------- 3 |NE 11 28 12 51 4 |N Cntrl 7 31 10 48 5 |South 46 23 14 83 6 |West 51 25 7 83 7 |Total 115 107 43 265 ---------------------------------------------------------------------------------- Notes: Tabulation of region agecat : group = 1 0 |1 2 3 4 5 ----+----------------------------------------------------------------------------- 1 | Census Region agecat 2 | 19-29 30-34 35+ Total ----+----------------------------------------------------------------------------- 3 |NE 11 27 13 51 4 |N Cntrl 7 30 10 47 5 |South 47 22 15 84 6 |West 51 24 8 83 7 |Total 116 103 46 265 ---------------------------------------------------------------------------------- Notes: Tabulation of region agecat : group = 2 0 |1 2 3 4 5 ----+----------------------------------------------------------------------------- 1 | Census Region agecat 2 | 19-29 30-34 35+ Total ----+----------------------------------------------------------------------------- 3 |NE 10 28 12 50 4 |N Cntrl 7 31 10 48 5 |South 46 23 14 83 6 |West 52 24 8 84 7 |Total 115 106 44 265 ---------------------------------------------------------------------------------- Notes:
Hi Dr. Shah — I’ve updated
asdocx
, but I’m still having issues usingtabdisp
. See example below:sysuse bplong.dta tabdisp when, c(bp) by(patient) concise
Results:
... ----------+--------------- 117 | Before | 161 After | 152 ----------+--------------- 118 | Before | 165 After | 174 ----------+--------------- 119 | Before | 149 After | 151 ----------+--------------- ...
Using
asdocx
:Tabulation of when 0 |1 2 ----+----------------------------------------------------------------------------- 1 |Status bp ----+----------------------------------------------------------------------------- 2 |Before 143 3 |After 153 ----------------------------------------------------------------------------------
asdocx
seems to be collapsing the data or only presenting one observation instead of separating out by PatientID.Any ideas?
Thanks,
KevinThe algorithm behind
tabdisp
is quite complex. Initially, I did not intend to include aby()
option. However, in response to your request, I have now added this feature. Please note that the output might slightly deviate from what is produced by Stata. This is currently the best achievable result. After updating asdocx, you can try the following exampleasdocx tabdisp when, c(bp) by(sex) concise replace Tabulation of bp : sex = 1 0 |1 2 ----+----------------------------------------------------------------------------- 1 |Status bp ----+----------------------------------------------------------------------------- 2 |Before 143 3 |After 153 ---------------------------------------------------------------------------------- Notes: Tabulation of bp : sex = Male 0 |1 2 ----+----------------------------------------------------------------------------- 1 |Status bp ----+----------------------------------------------------------------------------- 2 |Before 152 3 |After 149 ---------------------------------------------------------------------------------- Notes:
Fantastic! Thank you!
-
AuthorPosts
- You must be logged in to reply to this topic.