Forum Replies Created
-
AuthorPosts
-
Thank you for your valuable feedback. You can view your contribution in the
flexmat
help file, as I have incorporated your example into theappendmat
section. In the next update, I will also include your name in the acknowledgement section.I had originally planned to add titles and notes when using the
appendmat
subcommand at a later time, but your message has provided me with renewed motivation and I will try to find the time to work on it soon.”Thanks for bringing this up. I have improved the functionality of flexmat, and as a result, I have updated the asdocx files. To get the updates, use
asdocx_update
This thread will be useful to other users of asdocx and flexmat, therefore, I will provide a detailed reply.
Theappendmat
sub-command appends a flexmat file to the current asdocx file (that is is available in the global macro$active_flexmat_file
). Users must use the optionmatname()
when usingappendmat()
. The subcommand is similar toaddmat
, but with three main differences:1. Users do not have to specify the
location()
option asappendmat
automatically identifies the next available location and appends the flexmat file to it.2. Files written with flexmat are stored as associative arrays, therefore, they need to be converted back to matrices before appending them to other files. The sub-command
appendmat
takes care of this.3. The
addmat
subcommand can be used to add a matrix at any combination of rows and columns, potentially replacing an existing matrix or table. In contrast, theappendmat
command will always append the flexmat file to a new location, resulting in the addition of a new table to the file.Here is a typical use of the sub-command
appendmat
.* Specify the flexmat filename using asdocx asdocx setfile, save(First_Test) * Add contents to the file First_Test flexmat addrow, data(Year, Month, Day) r(1) flexmat addrow, data(2001, March, 21) r(2) * Add notes and title to the table flexmat addparts, title(Table: Test Results for Sample A) /// notes(Sample A was tested for contaminants X, Y, and Z.) * Create another flexmat file and add contents asdocx setfile, save(Second_Test) flexmat addrow, data(Make, Model, mpg) r(1) flexmat addrow, data(Ford, Explorer, 15) r(2) * Add notes and title to the table flexmat addparts, title(Table: Test Results for Sample B) /// notes(Sample B was tested for contaminants A, B, and C) * Create asdocx file and append the earlier two flexmat files to it asdocx, save(REPORT) text(MY REPORT) title replace flexmat appendmat, matname(First_Test) flexmat appendmat, matname(Second_Test) * Export the asdocx file to MS Word asdocx export
* Note on file names
Thesetfile
option of ‘asdocx’ causes ‘flexmat’ to store its files in the_asdoc
folder, located in the user’s current directory. This folder is hidden by default to avoid visual clutter and accidental deletion. In the examples given, the filesFirst_Test
andSecond_Test
are stored asFirst_Test.flexmat
andSecond_Test.flexmat
, respectively, in the hidden directory. Users do not need to specify the folder path or the extension, as flexmat automatically retrieves files from the hidden the directory and adds the.flexmat
extension.When users are confident that they no longer need to store the asdocx’s working files, they can use:
asdocx clear
This will delete all raw files in the “_asdoc” folder.
Thanks for reporting this. I have fixed it now. Please update and test the new version.
asdocx_update webuse citytemp2, clear asdocx tab region agecat, row replace Tabulation of region agecat 0 |1 2 3 4 5 ----+------------------------------------------------------------------------------------- 1 | Census region Age category 2 | 19–29 30–34 35+ Total ----+------------------------------------------------------------------------------------- 3 |NE 46 83 37 166 4 | 27.711 50 22.289 100 5 |N Cntrl 162 92 30 284 6 | 57.042 32.394 10.563 100 7 |South 139 68 43 250 8 | 55.6 27.2 17.2 100 9 |West 160 73 23 256 10 | 62.5 28.516 8.984 100 11 |Total 507 316 133 956 12 | 53.033 33.054 13.912 100 ------------------------------------------------------------------------------------------ Notes: First row has frequencies, and second row has row percentages.
in reply to: Could you add xtgcause statistics table to asdocx #17410Adding all community contributed packages to asdocx is a daunting endevour. I have added several of them to asdocx and shall add several others, given that such packages are widely used in the Stata community. I have added
xtgcause
to asdocx. First update asdocx withasdocx_update
. Here is a working example (I am using the dataset mentioned in the help file of
xtgcause
package.asdocx xtgcause y x, lag(1) replace Dumitrescu & Hurlin (2012) Granger non-causality test results 0 |1 2 3 ----+----------------------------------------------------------------------------- 1 |Stat value p-value ----+----------------------------------------------------------------------------- 2 |Lag order: 1 3 |W-bar 1.291 4 |Z-bar 0.650 0.515 5 |Z-bar tilde 0.259 0.796 ---------------------------------------------------------------------------------- H0: x does not Granger-cause y. H1: x does Granger-cause y for at least one panelvar (id). Click to Open File: C:\temp\MyFile.docx
in reply to: Results are appended to the same file | asdocx #17404The default setting in asdocx is to append results to the same file which you used previously in the
save()
option. If you did not use thesave()
option, then the default name of “Myfile.docx” is used.
If you want to save the results to a new file, use thesave()
option with filename in the brackets. So, to write results toResults2
, the code will be:bys activityear: asdocx sum amtfunded2 if clientstate1=="Maryland", save(Results2)
in reply to: Looping through datasets in folder #17399Let’s assume that you have a folder named
temp
in drivec
and you have several.dta
files in it. You wish to create a codebook from all the.dta
files and save them tocodebook.docx
file. The following code will do the job.local files : dir "c:/temp" files "*.dta" cd c:/temp foreach file in `files' { use `file' , clear asdocx codebook , save(codebooks.docx) }
in reply to: Number of decimals with very small numbers #17397For setting decimal points in an asdoc’x document, I encourage you to visit this page https://asdocx.com/decimal-points/. If you wish to change decimal points for a single column, see the Section 4 on the above page.
In the following example, I am setting 11 decimal points for the second column, note the
2
inc2_dec(11)
. If you wish to target another column, just change the#
part inc#_dec()
.sysuse auto asdocx reg pr2, replace c2_dec(11) nest Table: Regression results 0 |1 2 ----+----------------------------------------------------------------------------- 1 | (1) 2 |Variables pr2 ----+----------------------------------------------------------------------------- 3 |Intercept 06.165e-07*** 4 | (03.429e-08) 5 |Observations 74 6 |R2 0 ---------------------------------------------------------------------------------- Notes: Standard errors are in parentheses. *** p<.01, ** p<.05, * p<.1
You need to add the variable name in the loop, try this:
loc NextRow 2 flexmat reset flexmat addrow, data (Variable, Obs, Mean, Std.Dev., Max, Min) row(1) foreach var in twear tnonwear move comm mon oth { sum nrobot_`var' flexmat addrow, data (`var', `r(N)',`r(mean)', `r(sd)',`r(max)', `r(min)') row(`NextRow') dec(3) loc ++NextRow } asdocx export
asdocx uses
matcell()
,matrow()
andmatcol()
internally to constructs the frequency table. Therefore, users cannot use these options. If you must use these options and also need asdocx with tab command, the workaround is use the tab command twice: once with asdocx and second without asdocx. In the second case, you may added these options.in reply to: Output to Multiple Documents Simultaneously? #17379You can enter Stata codes and output inside the <pre> </pre> tags, e.g., <pre> some Stata code here </pre> This will appear as:
some Stata code here
Please also note that html converts the Stata’s local macro symbol
`
to code, therefore, you need to use the html escape sequence of ` instead of`
You can also write it as ` instead of `.in reply to: Output to Multiple Documents Simultaneously? #17376asdocx keeps backup of all the files it creates. These backups can be used to re-generate Excel, Word, Html, or Latex files. If you are writing to two files at the same time, you need to just remember the files names. Once they are ready for export, supply the file name in the
save()
option. In your case, you can export the two files with:asdocx export, save(Abstract Results Draft) asdocx export, save(Abstract Tables)
in reply to: “Tab” Conformability Error #17356When a table had a single column, the Excel routine will throw the mentioned error. This has been fixed. You may update asdocx.
in reply to: “Tab” Conformability Error #17339I agree that asdocx should report a proper error message, instead of the function’s conformability error. I shall work on it and update it. Having said that, you can overcome the no observation error with the
capture
prefix. Therefore, if there is any such error, the code will run without throwing the said error and breaking the execution of the rest of the code.sysuse auto , clear capture asdocx tab make foreign if make=="Subaru" & foreign==0
in reply to: shwing t values in the output with pred(t) #17333I have updated asdocx. The new version has a fix for the mentioned issue. You may update asdocx with:
asdocx_update
Adding the pictures’ upload feature is a bit tricky. However, you can post asdocx output in html format. Follow these steps:
1. Use the save(myfile.html) option with asdocx to save the output in html
2. Open the output file with text editor and copy the contents starting fromclass ="asdocxtable"> upto the</div>
. Paste it in the<pre>
</pre>
tags.
3. You shall see a formatted tableIn the following example, I have copied the mentioned contents from myfile.html file and simply pasted it below.
sysuse auto, clear asdocx sum, replace save(myfile.html)
Descriptive StatisticsVariable Obs Mean Std. Dev. Min Max price 74 6165.257 2949.496 3291 15906 mpg 74 21.297 5.786 12 41 rep78 69 3.406 0.99 1 5 headroom 74 2.993 0.846 1.5 5 trunk 74 13.757 4.277 5 23 weight 74 3019.459 777.194 1760 4840 length 74 187.932 22.266 142 233 turn 74 39.649 4.399 31 51 displacement 74 197.297 91.837 79 425 gear_ratio 74 3.015 0.456 2.19 3.89 foreign 74 0.297 0.46 0 1 Notes: -
AuthorPosts