Hi, guys,
I would like to measure the percentage of sample firms smaller than the firm for each country in each year.
But I don't know how to use loop to count the number of firms with a smaller asset volume than the specific firm.
For example, for company "01COMMUNIQUE LAB" in 1999, I want to know how many firms are with assets < 2472.
Data:
input name year totass
"01COMMUNIQUE LAB" 1999 2472
"01COMMUNIQUE LAB" 2000 13487
"01COMMUNIQUE LAB" 2001 5145
"01COMMUNIQUE LAB" 2002 2375
"01COMMUNIQUE LAB" 2003 635
"01COMMUNIQUE LAB" 2004 859
"01COMMUNIQUE LAB" 2005 703
"01COMMUNIQUE LAB" 2006 707
"01COMMUNIQUE LAB" 2007 2915
"01COMMUNIQUE LAB" 2008 2157
"0373849 B.C. LTD" 1999 4586
"0373849 B.C. LTD" 2000 4106
"0373849 B.C. LTD" 2001 3659
"0373849 B.C. LTD" 2002 3649
"0373849 B.C. LTD" 2003 7523
"0373849 B.C. LTD" 2004 6165
"0373849 B.C. LTD" 2005 5892
"0373849 B.C. LTD" 2006 18235
"0373849 B.C. LTD" 2007 34371
"0373849 B.C. LTD" 2008 4831
Code:
egen yeargroup = group(year)
sort year
foreach var yeargroup{
gen Size == 0;
if totass[_n] > totass[_n+1]{
relsize ==relsize + 1;
}
}
It turns out not working. Could somebody help me with the commands?
Thanks in advance.
Xiao
Related Posts with Command problem with counting sample firms smaller than the firm for each country in each year (panel data)
Using svyset for melogitHello, I am analyzing a binary outcome (depvar) using melogit so that I may 1) account for the comp…
Suest command with more than 300 modelsHi all, I'm estimating arond 1000 models where the only thing that changes is the dependent variabl…
Wildcards with noccurHi there, Can I use wildcards with the egen function noccur? If not, is there another way to use wi…
How can I extract a portion of a string variable using regular expressions?Hi everyone! Thanks in advance for your time and help. I have the following problem....Some of the …
qreg converges in Stata/IC 15.0 (& gives reasonable standard errors), but fails to converge in Stata/MP 17.0Dear All, I have a household-level dataset of 511,877 observations, and run a quantile regression o…
Subscribe to:
Post Comments (Atom)
0 Response to Command problem with counting sample firms smaller than the firm for each country in each year (panel data)
Post a Comment