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

st: using egen & fill coupled to another variable?


From   peter <[email protected]>
To   [email protected]
Subject   st: using egen & fill coupled to another variable?
Date   Sun, 26 Jan 2003 10:47:00 -0800

Hello,

Forgive me if this is to simple a question, but I cannot seem to make this 
work:

I want to use:

 egen x1=fill(1 1 1 2 1 1 1 2)

but wish to have values '1' correspond to a percentage of value '1' in another 
variable x2.

For example,

 if x2 = 1, the egen and fill should generate a '1' say, 70% of the time, and 
a '2' 30% of the time for variable x1

similarly  if x2 = 2, the egen and fill should generate a '2' say, 70% of the 
time, and a '1' 30% of the time for variable x1

I'm sure this is very simple, but so far no joy in getting it to work.
I need a solution for over 100 generated variables, so a 'one-off' solution 
will not be too useful.

Thanks very much for any help you can give.
--Peter


--------------------------------------
Dr. P. Reece
[email protected]
--------------------------------------
*
*   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