由买买提看人间百态

boards

本页内容为未名空间相应帖子的节选和存档,一周内的贴子最多显示50字,超过一周显示500字 访问原贴
Economics版 - a question about stata code
相关主题
cross sectional data的fixed effect3-stage equation
关于stata的一个问题[合集] 请教一个有关panel data analysis using STATA的问题
Question about Panel data regression请教 lagged variable,多谢:P
问个计量问题,Help with Stata Macro
请问关于stata simulation请教一个有关stata的简单操作~~
[合集] 请教在STATA中如何简写一系列file names,谢谢问一个STATA问题:Interaction between dummy and continuous variable
[合集] 计量经济学问题--高手请进About discussions on the topic of deregualtion in Power industry
问个简单的计量问题[合集] 有大侠知道怎样比较GMM和ML和QML等用于同一个数据的有效性吗?
相关话题的讨论汇总
话题: generate话题: p1话题: gen话题: d1话题: d2
进入Economics版参与讨论
1 (共1页)
j***m
发帖数: 74
1
i have a set of dummies, say d1 d2...d9, and i have another variable, say p.
now i want to multiply each dummy by p, and generate a new set of variable,
say pd1=p*d1,pd2=p*d2,....
how can i do that in once. i know the cumbersome and stupid way is to
generate one by one, like
gen pd1=p*d1
gen pd2=p*d2
...
thanks.
h****i
发帖数: 1674
2
if p1 to pn are stored in the order of 1-n in the memory, you can write
codes like these in you do file
foreach var in vallist p1-pn {
gen p`var'=p*`var'
}
you can search help file for foreach to see the details
a**n
发帖数: 3801
3
http://www.stata.com/help.cgi?xi
xi i.d1*p

p.
variable,

【在 j***m 的大作中提到】
: i have a set of dummies, say d1 d2...d9, and i have another variable, say p.
: now i want to multiply each dummy by p, and generate a new set of variable,
: say pd1=p*d1,pd2=p*d2,....
: how can i do that in once. i know the cumbersome and stupid way is to
: generate one by one, like
: gen pd1=p*d1
: gen pd2=p*d2
: ...
: thanks.

j***m
发帖数: 74
4
Thanks all. I will try tomorrow.
j***m
发帖数: 74
5
The xi command workd great. Thanks a lot

【在 a**n 的大作中提到】
: http://www.stata.com/help.cgi?xi
: xi i.d1*p
:
: p.
: variable,

j***m
发帖数: 74
6
new question comes.
since in my model, I have two firms, and I have one indicator for each firm,
say p1,p2. and another set of product dummies.
I know by xi I can generate p1*d(n), but since I need to generate p1*d(n)
and p2*d(n) at the same time, and if I use xi and generate p1*d(n) first and
p2*d(n) second, p2*d(n) will replace p1*d(n), and I only get p2*d(n).
Another problem is by using xi, it not only generates p*d(n), but also
generate d(n), so every time I have to drop d(n) after I generat
g****s
发帖数: 39
7
use do file
forval i=1/m {
forval j=1/n{
gen p`i'_d`j'=p`i'*d`j'
}
}

firm,
and

【在 j***m 的大作中提到】
: new question comes.
: since in my model, I have two firms, and I have one indicator for each firm,
: say p1,p2. and another set of product dummies.
: I know by xi I can generate p1*d(n), but since I need to generate p1*d(n)
: and p2*d(n) at the same time, and if I use xi and generate p1*d(n) first and
: p2*d(n) second, p2*d(n) will replace p1*d(n), and I only get p2*d(n).
: Another problem is by using xi, it not only generates p*d(n), but also
: generate d(n), so every time I have to drop d(n) after I generat

1 (共1页)
进入Economics版参与讨论
相关主题
[合集] 有大侠知道怎样比较GMM和ML和QML等用于同一个数据的有效性吗?请问关于stata simulation
请教[合集] 请教在STATA中如何简写一系列file names,谢谢
relationship between CAPEX and revenue / operating income[合集] 计量经济学问题--高手请进
What about Data Crunching Club?问个简单的计量问题
cross sectional data的fixed effect3-stage equation
关于stata的一个问题[合集] 请教一个有关panel data analysis using STATA的问题
Question about Panel data regression请教 lagged variable,多谢:P
问个计量问题,Help with Stata Macro
相关话题的讨论汇总
话题: generate话题: p1话题: gen话题: d1话题: d2