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

st: Re: A problem with egen??


From   "George M Hoffman MD" <[email protected]>
To   <[email protected]>
Subject   st: Re: A problem with egen??
Date   Tue, 3 May 2005 18:44:05 -0500

you are repeating the egen on the whole sample, as you found out.
you want to have the 'by' as a modifier of egen. 
try:
egen X_5 = pct(X), by(country)

george hoffman

----- Original Message ----- 
From: "heisnam singh" <[email protected]>
To: <[email protected]>
Sent: Tuesday, May 03, 2005 6:05 PM
Subject: st: A problem with egen??


Dear Statalist users,
 I am having a problem in using the egen command.My
dataset has many countries. I want to generate a
variable which takes value= 5th (or  any) percentile
value of another variable for each country.  I  tried
this :

sort country   
by country:egen X_5pct=pct(X), p(5)

I am getting the same value for all the countries,
which  is the 5th percentile value of the entire
sample. Whereas I want the 5th percentile value for
each country separately.

However if I do without specifying the option p(5)

sort country   
by country:egen X_5pct=pct(X)

Then I get the median (50th percentile value) for each
country separately. But whenever I tried with the
option p(5), I get the value for the entire sample.

Please help me out. 

Thoihen

__________________________________________________
Do You Yahoo!?
Tired of spam?  Yahoo! Mail has the best spam protection around 
http://mail.yahoo.com 
*
*   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