查看文件
dir auto.dta
打开数据auto训练数据
use auto
查看数据结构
describe
#查看数据
edit
If语句
edit make price rep78 headroom if foreign==1 & price>1000
清除
clear
in
edit in 10/5
edit in 5/10
edit in 5/10 if price>1000
查看分布
summarize price trunk weight if foreign==1
summarize price trunk weight if foreign
产生数据
generate weight_price=weight + price
generate weight_price=weight+price if foreign==1 #出错:weight_price already defined
#出错原因:weight_price 已经用过了
#解决方法:换个名字或者删去之前的数据或者replace weight_price=weight+price
替换
replace weight_price=weight+price
计算平方根
generate sqrt_price=sqrt(price)
edit sqrt_price
更改
replace sqrt_price=sqrt_price^(1/2) if foreign==0
label
label variable sex “性别”
save
保存修改过的
save,replace
input
input sex
dir
dir *.dta
查找dta结尾的文件
doedit
doedit hyq.do
# 编辑do文件
Doedit hyq1
*===April 28
cd
dir
use auto
describe
generate sqrt_price=sqrt(price)
label variable sqrt_price "price变量平方根"
label dir
label list origin
*===end
Run hyq1
*====2021-4-21===
cd//check directory
dir//路径
clear//清除
use///换行加注释,三个反斜杠
page27_5_2/*hhh*/
describe
edit
generate sqrt_salary=/*hhh
h*/sqrt(salary)
viewsource hyq.do
set more off
capture log close
log using hyq.log,append
clear
*===April 28
cd
dir
use auto
describe
generate sqrt_price=sqrt(price)
label variable sqrt_price "price变量平方根"
label dir
label list origin
*===end
log close
===2021-5-7==
capture log close
log using hyq.log,replace
cd
dir
//input data
input id salary education origin_wage experience
1 57000 15 27000 14
2 40200 16 18750 36
3 21450 12 12000 381
4 21900 8 13200 190
5 45000 15 21000 138
6 28340 8 12000 26
end
mkmat salary education origin_wage experience ,mat(X)
matrix list X
//computarion
matrix I6=I(6)
matrix list I6
matrix unit=vecdiag(I6)'
matrix list unit
matrix X_bar=X'*unit/6
matrix list X_bar
matrix cross_product=X'*(I6-1/6*unit*unit')*X
matrix list cross_product
matrix covariance=1/5*cross_product
matrix list covariance
log close
===2021-5-7==
capture log close
log using hyq.log,replace
cd
dir
//input data
input id salary education origin_wage experience
1 57000 15 27000 14
2 40200 16 18750 36
3 21450 12 12000 381
4 21900 8 13200 190
5 45000 15 21000 138
6 28340 8 12000 26
end
mkmat salary education origin_wage experience ,mat(X)
matrix list X
//computarion
matrix I6=I(6)
matrix list I6
matrix unit=vecdiag(I6)'
matrix list unit
matrix X_bar=X'*unit/6
matrix list X_bar
matrix cross_product=X'*(I6-1/6*unit*unit')*X
matrix list cross_product
matrix covariance=1/5*cross_product
matrix list covariance
log close
=========================================