asdoc Unicode issue | Stata to MS Word

  • 1

asdoc Unicode issue | Stata to MS Word

Category:Uncategorized

For those who are not yet familiar with asdoc, asdoc can be downloaded from SSC and can be used with almost all Stata commands. Here is a short blog post that shows how asdoc can be used with any Stata command. You can also watch several YouTube videos that show the use of asdoc


asdoc installation

 ssc install asdoc


The problem

Since asdoc uses RTF file format, any Unicode character passed from Stata to the RTF file will be incorrectly shown in the output file. For example, a variable has the following value label which is correctly shown on Stata screen, but when written with asdoc, it is distorted.

Stata view: Don’t know
asdoc view: 

The solution

If you have Stata 14 or higher, then the good news is that you can use unicode command to change the file encoding. Specifically, the subcommand convertfile of unicode command can be extremely useful here. In the following example, I shall download an example dataset, called unicode.dta from my site, and then tabulate the variable M25 with asdoc, write the results to Myfile.doc and convert the coding and write the results to a new file, Myfile_new.doc

use http://fintechprofessor.com/unicode.dta, clear
asdoc tab M25, replace

The file generated by asdoc looks like this, the last line of the file highlights the given issue.

Now lets try the unicode solution.

unicode convertfile  Myfile.doc  Myfile_new.doc, dstencoding(Windows-1252) replace

1 Comment

NAILA

May 24, 2019at 10:52 pm

If you have Stata 14 or higher, then the good news is that you can use unicode command to change the file encoding………..
BUT IF WE HAVE STATA 13 THEN SOLUTION?????

Leave a Reply

3 × 1 =