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" <>
To   <>
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. 
egen X_5 = pct(X), by(country)

george hoffman

----- Original Message ----- 
From: "heisnam singh" <>
To: <>
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. 


Do You Yahoo!?
Tired of spam?  Yahoo! Mail has the best spam protection around 
*   For searches and help try:
*   For searches and help try:

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