楼主: 天使键小黑
11782 5

[编程问题求助] Label already defined [推广有奖]

  • 0关注
  • 0粉丝

学前班

60%

还不是VIP/贵宾

-

威望
0
论坛币
0 个
通用积分
0
学术水平
0 点
热心指数
0 点
信用等级
0 点
经验
23 点
帖子
2
精华
0
在线时间
1 小时
注册时间
2014-8-22
最后登录
2014-12-6

楼主
天使键小黑 发表于 2014-11-25 17:42:38 |AI写论文

+2 论坛币
k人 参与回答

经管之家送您一份

应届毕业生专属福利!

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

经管之家联合CDA

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

感谢您参与论坛问题回答

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

+2 论坛币
这两天做quantile regression+绘图的时候遇到这样的问题:
我的代码是这样的:
. set more off
. save tempcf, replace emptyok  
file tempcf.dta saved
.
. forvalues q = 0.05(0.05)0.95 {
  2.   quietly rifreg lgw parent age $Educ $Work $health if work == 1 & female==1, quantile(`q') w(0.06)
  3.   matrix B=e(b)
  4.   svmat double B, name(coef)
  5.   gen quant=`q'
  6.   keep quant coef*
  7.   keep if _n==1  
  8.   append using tempcf
  9.   save tempcf, replace
10.  }

然后报错:
(14859 observations deleted)
(label d40 already defined)
(label d38 already defined)
(label d37 already defined)
(label d28 already defined)
(label d26 already defined)
(label d25 already defined)

file tempcf.dta saved
new variables cannot be uniquely named or already defined
r(110);

我检查了,原来并没有coef* 或者quant变量在我的varlist里面,
但是我找不到already defined 的变量是那个QAQ

求助~~

二维码

扫码加我 拉你入群

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

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

关键词:Defined Already DEFINE Ready label already

沙发
ermutuxia 发表于 2014-11-27 20:46:52
可以用capture drop命令删除
已有 1 人评分经验 学术水平 热心指数 收起 理由
SpencerMeng + 60 + 1 + 1 观点有启发

总评分: 经验 + 60  学术水平 + 1  热心指数 + 1   查看全部评分

藤椅
天使键小黑 发表于 2014-12-6 10:00:23
ermutuxia 发表于 2014-11-27 20:46
可以用capture drop命令删除
我drop了所有的label还是会报错QAQ

板凳
SpencerMeng 在职认证  发表于 2014-12-6 10:43:20
天使键小黑 发表于 2014-12-6 10:00
我drop了所有的label还是会报错QAQ
不只是label的问题

new variables cannot be uniquely named or already defined

你的新变量不能唯一的命名或者说你的新变量已经被定义了

建议你再好好检查下自己的变量,des下,再仔细阅读下自己的code,排查原因。没有人比你更了解自己的东东了,加油~!
已有 1 人评分学术水平 热心指数 信用等级 收起 理由
yz2008 + 1 + 1 + 1 精彩帖子

总评分: 学术水平 + 1  热心指数 + 1  信用等级 + 1   查看全部评分

报纸
盖世xiong 发表于 2015-11-8 15:48:07
set more off
save tempcf, replace emptyok  

*** adjust the parameters of the forvalues command to estimate the quantiles of choice
*** in this example, the estimation is done at every fifth centile
*** you can remove quietly if you want to see the rif-regression results
forvalues q = 0.05(0.05)0.95 {
  use usmen0305_two, clear
  quietly rifreg lwage union educ exp expsq, quantile(`q') w(0.06)
  matrix B=e(b)
  svmat double B, name(coef)
  gen quant=`q'
  keep quant coef*
  keep if _n==1  
  append using tempcf
  save tempcf, replace
}

use tempcf, clear
sort quant
label var quant "Quantile"
*** choose the coefficient(s) that you want to graph, here coef1 is the coefficient of union coverage
graph twoway (connected coef1 quant if quant>0.0 & quant<1.0  ) /*
   */, xlabel(0.0 0.2 0.4 0.6 0.8 1.0) title("Union Premium") ytitle(" ") /*
   */  yline(0.0, lw(thin) lc(black)) saving(unionpr1,replace)

graph export unionpr1.wmf, replace
这是原文,tempcf是用于存储回归结果了,在循环的时候却要一次次调用回归所需要的数据文件。你的回归根本没有调用。在循环一次后你的语句就死掉了,因为此时的数据已经转化为tempcf,没有你用来回归的变量了亲。。不要以为作者写的语句是废话。。。

地板
newfei188 发表于 2016-10-21 00:04:59
I MEET THE SAME PROBLEM

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

本版微信群
加好友,备注jltj
拉您入交流群
GMT+8, 2026-1-7 22:09