全部版块 我的主页
论坛 计量经济学与统计论坛 五区 计量经济学与统计软件 Stata专版
1012 4
2017-05-06
use "D:\2016-2017博士生涯\博士生涯\数据整理\inventor\哈佛数_3\Class\class_A110.dta", clear
preserve
drop if number_1 !=1
local a = gyear_inventor_lo
local b = gyear_inventor_up
local c = class_4digit
restore
keep if gyear >= `a'& gyear <= `b'
gen explor = 1
replace explor = 0 if strpos(class_4digit,"`c'")
keep if explor == 0
save "D:\2016-2017博士生涯\博士生涯\数据整理\inventor\哈佛数_3\1.dta"

use "D:\2016-2017博士生涯\博士生涯\数据整理\inventor\哈佛数_3\Class\class_A110.dta", clear
preserve
drop if number_1 !=2
local a = gyear_inventor_lo
local b = gyear_inventor_up
local c = class_4digit
restore
keep if gyear >= `a'& gyear <= `b'
gen explor = 1
replace explor = 0 if strpos(class_4digit,"`c'")
keep if explor == 0
save "D:\2016-2017博士生涯\博士生涯\数据整理\inventor\哈佛数_3\2.dta"
···
use "D:\2016-2017博士生涯\博士生涯\数据整理\inventor\哈佛数_3\Class\class_A110.dta", clear
preserve
drop if number_1 != n
local a = gyear_inventor_lo
local b = gyear_inventor_up
local c = class_4digit
restore
keep if gyear >= `a'& gyear <= `b'
gen explor = 1
replace explor = 0 if strpos(class_4digit,"`c'")
keep if explor == 0
save "D:\2016-2017博士生涯\博士生涯\数据整理\inventor\哈佛数_3\n.dta"
二维码

扫码加我 拉你入群

请注明:姓名-公司-职位

以便审核进群资格,未注明则拒绝

全部回复
2017-5-6 10:17:11
stata循环语句,里面有一个变量是number_1,从1循环到n,循环语句怎么写呢?中间部分都没有问题,就是怎么循环然后保存到以1-n结尾的文件呀
二维码

扫码加我 拉你入群

请注明:姓名-公司-职位

以便审核进群资格,未注明则拒绝

2017-5-6 16:09:18
已解决
二维码

扫码加我 拉你入群

请注明:姓名-公司-职位

以便审核进群资格,未注明则拒绝

2017-5-7 09:18:10
scdx11327yjy1 发表于 2017-5-6 16:09
已解决
分享一下解决办法吧~
二维码

扫码加我 拉你入群

请注明:姓名-公司-职位

以便审核进群资格,未注明则拒绝

2017-5-7 11:33:10
夏目贵志 发表于 2017-5-7 09:18
分享一下解决办法吧~
forvalues i = 1/4 {
use "D:\2016-2017博士生涯\博士生涯\数据整理\inventor\哈佛数_3\Class\class_A110.dta", clear
preserve
drop if number_1 != `i'
local a = gyear_inventor_lo
local b = gyear_inventor_up
local c = class_4digit
restore
keep if gyear >= `a'& gyear <= `b'
gen explor_`i' = 1
replace explor_`i' = 0 if strpos(class_4digit,"`c'")
keep if explor_`i' == 0
save "D:\2016-2017博士生涯\博士生涯\数据整理\inventor\哈佛数_3\_`i'.dta",replace
}
二维码

扫码加我 拉你入群

请注明:姓名-公司-职位

以便审核进群资格,未注明则拒绝

栏目导航
热门文章
推荐文章

说点什么

分享

扫码加好友,拉您进群
各岗位、行业、专业交流群