Stata solves the problem of Chinese path installation (super useful!!!)

Table of contents

1. Introduction to the problem

2. Set the installation path

3. Case


1. Introduction to the problem

When installing external commands, an error message " cannot write in directory C:\Users\�ַ�\ado\plus\l " may appear . This is because the permissions of this folder are not desirable. Simply put, the path appears in Chinese character. The installation path of Stata is required to be in English and cannot contain Chinese characters, so the situation that may be encountered during the installation process:

 At this point, we check the current installation and working path of stata, enter " sysdir ", you can see in the figure below, the location of folders such as stata, base, site, plus, personal, oldplace, etc., where the base folder is used to store Stata The built-in basic commands, the plus folder is used to store external commands, and the personal is used to store commands and do files written by yourself.

The external commands we download are usually in  .ado  format, and are usually stored in the plus folder in the ado folder. When the user (Users) name is set to Chinese, Stata will display "cannot write in directory" and cannot read the file folder, causing the installation to fail, and it is generally difficult to modify the computer user name, so how to solve such a problem? Let's introduce a program that can perfectly solve such problems.

2. Set the installation path

Generally speaking, Stata software is installed on the D disk or other disks, and the folder downloaded by external commands is usually still on the C disk. The following program can help us set the location of external command downloads:

adopath+"G:\stata17\ado\plus" //显示当前stata路径
clear all
sysdir set PLUS "G:\stata17\ado\plus"  //设置外部命令存放方式
sysdir set PERSONAL "G:\ado\person"  //设置用户个人编写的命令的存储位置
sysdir set OLDPLACE "G:\ado\oldplace"
sysdir

Run this program, and save this program under the stata installation path, as shown in the figure:

At this point, you can see that after the program runs, the working path of stata changes, as shown in the figure:

 As can be seen from the figure above, the working path of Stata has been modified, and the paths of the plus, personal, and oldplace folders have been modified to the G drive. After running the above steps, Stata can use the previously installed commands, whether you use ssc  ,  search , net  , findit  or  github , you can install the commands to the current plus folder!

Rerun the code just now

ssc install logout

You can see that the logout command is downloaded directly to the G:\stata17\ado\plus\ folder. As long as the installation path is set before installation, the problem of installing external commands can be perfectly solved!!!

3. Case

Put today's homework up to make up the number (hhh)

clear
sysuse auto, clear
rename price y
rename mpg fdi
reg y fdi
est sto  yl1  
gen lny=log(y)
gen lnfdi=log(fdi)
reg lny lnfdi
est sto  yl2 
reg y fdi,r
est sto  yl3 
reg y fdi
predict e, r
gen ln_e2=log(e*e)
reg ln_e2 fdi
predict ghat,xb/*前面四步都是为了这一步,这一步是在预测拟合值,xb可以删掉*/
gen se=exp(ghat) 
reg y fdi[aw=1/se]
est sto  yl4 
local d  "using "C:\Users\230468\Desktop\11.rtf""        // 输出到指定地方的word文档中
local a  "yl1 yl2 yl3 yl4 "                   
esttab `a' using "G:\work\01.rtf", b(%6.4f) se(%6.4f) nogap compress   ///
    star(* 0.1 ** 0.05 *** 0.01)  ///
    ar2 scalar(N) replace         ///
    // 使得回归结果中不报告虚拟变量的系数,而且用Yes进行设置)

Finally generate an rtf file:

 

Guess you like

Origin blog.csdn.net/weixin_60200880/article/details/129623570