Bookmark and Share

Notice: On March 31, it was announced that Statalist is moving from an email list to a forum. The old list will shut down on April 23, and its replacement, is already up and running.

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

st: loops for regions

From   Chiara Mussida <>
To   statalist <>
Subject   st: loops for regions
Date   Wed, 5 Sep 2012 18:15:53 +0200

Dear All,
I want to generate a variable herf1 which takes the value of the below
index for region 1, and thereafter repeat this loop for all the region
in my dataset. The problem is that with the below command I get the
herf1 index for region 1, which is identycal in value (I tried) to the
herf2 for region2 whether I repeat this llop for region2, by starting
with "if reg==2, and so forward for all the regions.

if reg==1 {
tab cat12_2, gen(categ)
forvalues k = 1 2 to 12 {
sum categ`k', meanonly
	gen share`k'=r(mean) if reg==1 /*shares of each occ cat on the total
occupation, time t*/

gen herf1=(share1)^2 + (share2)^2 + (share3)^2 + (share4)^2 +
(share5)^2 + (share6)^2 + (share7)^2 + (share8)^2 ///
+ (share9)^2 + (share10)^2 + (share11)^2 + (share12)^2  /*Herfindhal
Index Region1*/
the variable reg takes 1 for region1, 2 for region2...up to 20 for
region20. In other words, Stata does not compute the specific index
for each region, but the same index region by region.


Chiara Mussida
PhD candidate
Doctoral school of Economic Policy
Catholic University, Piacenza (Italy)
*   For searches and help try:

© Copyright 1996–2016 StataCorp LP   |   Terms of use   |   Privacy   |   Contact us   |   Site index