现在复制一篇文章的数据分析,里面大量使用了local命令。请问连老师在我们视频里有具体讲解吗 在下面的命令使用中 是什么意思 您只需要讲解local命令的一般使用情况即可 如果信息不足需要添加 我会补充
非常感谢
/*------------------Set initial conditions----------------*/
gen Tinit=67
gen Tlast=96
gen ageinit=20
gen agelast=64
gen agecell=4
gen minyrs=20
gen nlag=29
gen agelb=19
/*If agecell is an odd number, add 1 to get an integer*/
gen ageub=agelb+agecell
gen agemidpt = (agelb+ageub)/2
gen agemax = (agelast+agelast-agecell)/2 - (ageub+agelb)/2
/*midpt of oldest cell*/ /*midpt of youngest*/
gen oldcoh=agelast-minyrs-ageinit /*----------------The number of cohorts already existing in year Tinit--------------*/
gen newcoh=(Tlast-(minyrs-1)-(Tinit+1)) /*----------------The number of cohorts to enter after year Tinit-----------------*/
gen maxcoh=oldcoh+newcoh /*-----------------The total number of cohorts-------------------*/
local i=94
while `i'<=97 {
rename upedu`i'h grade`i'
local i=`i'+1
}
/*--------IMPUTING MISSING GRADES VARIABLE IN THE YEARS 70-74-------------*/
replace grade72=edcn72
replace grade72=. if grade72>25
replace grade75=edcn75
replace grade75=. if grade75>25
gen grade69=0
replace grade69=grade68 if seqno68==1 & seqno69==1
replace grade69=grade72 if grade69==0 & seqno69==1 & seqno72==1
replace grade70=grade68 if seqno68==1 & seqno70==1
replace grade70=grade72 if grade69==0 & seqno70==1 & seqno72==1
replace grade71=grade70 if seqno70==1 & seqno71==1
replace grade71=grade72 if grade71==0 & seqno71==1 & seqno72==1
replace grade73=grade72 if seqno72==1 & seqno73==1
replace grade73=grade75 if grade73==0 & seqno73==1 & seqno75==1
replace grade74=grade72 if seqno72==1 & seqno74==1
replace grade74=grade75 if grade74==0 & seqno74==1 & seqno75==1
/*---------REMOVING MISSING OBSERVATIONS IN GRADES-----------*/
local i=Tinit+1
while `i'<=Tlast+1 {
replace grade`i'=. if grade`i'>30
local i=`i'+1
}