楼主: scdx11327yjy1
1058 4

[作图问题求助] 敢问大神们,以下循环语句怎么搞啊 [推广有奖]

  • 1关注
  • 13粉丝

已卖:1504份资源

讲师

44%

还不是VIP/贵宾

-

威望
0
论坛币
35574 个
通用积分
50.6096
学术水平
6 点
热心指数
7 点
信用等级
6 点
经验
4427 点
帖子
144
精华
0
在线时间
850 小时
注册时间
2016-5-26
最后登录
2025-12-17

楼主
scdx11327yjy1 学生认证  发表于 2017-5-6 10:11:40 |AI写论文

+2 论坛币
k人 参与回答

经管之家送您一份

应届毕业生专属福利!

求职就业群
赵安豆老师微信:zhaoandou666

经管之家联合CDA

送您一个全额奖学金名额~ !

感谢您参与论坛问题回答

经管之家送您两个论坛币!

+2 论坛币
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"
二维码

扫码加我 拉你入群

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

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

关键词:循环语句 Inventor preserve Reserve restore

沙发
scdx11327yjy1 学生认证  发表于 2017-5-6 10:17:11
stata循环语句,里面有一个变量是number_1,从1循环到n,循环语句怎么写呢?中间部分都没有问题,就是怎么循环然后保存到以1-n结尾的文件呀

藤椅
scdx11327yjy1 学生认证  发表于 2017-5-6 16:09:18
已解决

板凳
夏目贵志 发表于 2017-5-7 09:18:10
scdx11327yjy1 发表于 2017-5-6 16:09
已解决
分享一下解决办法吧~

报纸
scdx11327yjy1 学生认证  发表于 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
}
已有 1 人评分经验 收起 理由
夏目贵志 + 5 鼓励积极发帖讨论

总评分: 经验 + 5   查看全部评分

您需要登录后才可以回帖 登录 | 我要注册

本版微信群
加好友,备注jltj
拉您入交流群
GMT+8, 2025-12-31 05:51