Stata The Stata listserver
[Date Prev][Date Next][Thread Prev][Thread Next][Date index][Thread index]

RE: st: Generate a new variable [four firm concentration ratio]


From   "Nick Cox" <[email protected]>
To   <[email protected]>
Subject   RE: st: Generate a new variable [four firm concentration ratio]
Date   Mon, 21 Nov 2005 23:57:22 -0000

The line within the loop should be 

replace firstfour = firstfour + s`i' if s`i' >= 0 

Nick 
[email protected] 

> -----Original Message-----
> From: [email protected]
> [mailto:[email protected]]On Behalf Of Nick Cox
> Sent: 21 November 2005 23:55
> To: [email protected]
> Subject: RE: st: Generate a new variable [four firm 
> concentration ratio]
> 
> 
> I think I follow some of this, although I cannot 
> reproduce the capricious behaviour you seem 
> to imply here. I would like to see a copy of 
> (a subset of) your data that apparently produces 
> this problem. Strictly, it implies a bug in Stata's 
> -numlist- command, which does the sorting here. 
> 
> The help for -rowsort- indicates that missing values 
> are allowed. If you sort seven values, some of which 
> are missing, the missing values will not disappear!
> (Or did you expect they would?) Following usual Stata 
> rules they will be sorted to high values. 
> 
> You are correct that this then will not be what you want. 
> 
> One way round this is to use -mvencode- to map 
> missings to some negative number, say -999, presuming
> that is not a legitimate number of consumers. These 
> will always sort lower than any legitimate number. 
> Then the sum of the first four firms should trap 
> any -999. However, if any of the first four firms 
> is missing, and so mapped to -999, then the concentration 
> ratio should presumably be 100%. 
> 
> drop s1-s7 
> mvencode F?mt, mv(-999) 
> rowsort F?_mt, gen(s1-s7) descend
> 
> replace firstfour = 0 
> forval i = 1/4 { 
> 	replace firstfour = s`i' if s`i' >= 0 
> } 
> replace firstfour = 100 * firstfour / CONSUM_mt 
> 	
> mvdecode F?mt, mv(-999) 
> 
> Nick 
> [email protected] 
> 
> ALICE DOBSON
>  
> > Thanks Nick. It works selectively as I am not getting 
> > "firstfour" for all 
> > rows.
> > This is probably because the rows have values for one to 
> > seven firms and not 
> > for all seven firms
> > Further, I checked the data editor and see that in such cases 
> > where the data 
> > is avaiable for less than seven firms the command arranges 
> > the top four 
> > values s1-s4 (arbitrarily) in columns for say s3-s6
> > Hence, I do not get firstfour for all such cases
>  
> > >From: n j cox <[email protected]>
> > >Reply-To: [email protected]
> > >To: [email protected]
> > >Subject: Re: st: Generate a new variable [four firm 
> > concentration ratio]
> > >Date: Mon, 21 Nov 2005 21:31:19 +0000
> > >
> > >If the number of consumers is integer, then
> > >just install -rowsort- from SSC.
> > >
> > >rowsort F?_mt, gen(s1-s7) descend
> > >gen firstfour = 100 * (s1 + s2 + s3 + s4) / CONSUM_mt
> > >
> > >Nick
> > >[email protected]
> > >
> > >ALICE DOBSON
> > >
> > >I use stata 9.1
> > >
> > >I have an unbalanced panel data of the type:
> > >
> > >geographical region (m = 1..1154)
> > >year (t = 1..7)
> > >
> > >with the following variables:
> > >
> > >total number of consumers in each region (CONSUM_mt)
> > >total number of consumers of seven firms in each region 
> > (F1_mt, F2_mt, 
> > >F3_mt, F4_mt, F5_mt, F6_mt, F7_mt)
> > >
> > >
> > >I want to calculate the four firm concentration ratio for 
> > each region, 
> > >C4_mt, which is the proportion of the number of consumers of 
> > top four firms 
> > >to the total number of consumers in that region, in percentage
> > >
> > >Could anyone be kind enough to help me with this simple 
> calculation?
> > >
> > >GEOGREGN YEAR CONSUM F1 F2 F3 F4 F5 F6 F7 C4
> > >M1 1969
> > >M1 1970
> > >M1 1971
> > >M1 1972
> > >M1 1973
> > >M1 1974
> > >M1 1975
> > >M2 1969
> > >M2 1970
> > >M2 1971
> > >M2 1972
> > >.
> > >.
> 
> *
> *   For searches and help try:
> *   http://www.stata.com/support/faqs/res/findit.html
> *   http://www.stata.com/support/statalist/faq
> *   http://www.ats.ucla.edu/stat/stata/
> 

*
*   For searches and help try:
*   http://www.stata.com/support/faqs/res/findit.html
*   http://www.stata.com/support/statalist/faq
*   http://www.ats.ucla.edu/stat/stata/



© Copyright 1996–2024 StataCorp LLC   |   Terms of use   |   Privacy   |   Contact us   |   What's new   |   Site index