Hi Stata Users
I am using this code below and it is working very well:
and then I use this code which is also working very well:
my question is about
. In fact I do not know the exact number of "j"s. So I need to calculate first the maximum number of "j"s. The number could be 8, but also 10 or 12.
I tried using
, which is obviously wrong and did not work. Is there any way to do that? And how would my second code change?
Do I have to provide data example for this question?
Thank you
Max
I am using this code below and it is working very well:
Code:
bysort ID_com time: gen all=sum(v_local!=v_local[_n-1])
forval j=1/8{
egen v_local`j'=mean(cond(all==`j', v_local, .)), by (ID_com time)
}
Code:
gen byte trade_var= inlist(domestic,v_local1,v_local2,v_local3,v_local4,v_local5,v_local6,v_local7,v_local8)
Code:
forval j=1/10
I tried using
Code:
forval j=1/max`j'
Do I have to provide data example for this question?
Thank you
Max

Comment