Notice: On April 23, 2014, Statalist moved from an email list to a forum, based at statalist.org.

# st: Create new distribution under certain criteria

 From Nikolaos Kanellopoulos <[email protected]> To "[email protected]" <[email protected]> Subject st: Create new distribution under certain criteria Date Sun, 24 Jun 2012 20:09:09 +0100 (BST)

```Dear all,
This is
more of a statistical rather than a Stata specific question.
I have two
series. One is constantly positive (y) and the other can be negative but with a
positive mean (x). I want to create a third series (newx) which will be a
transformation of x but it must always be positive and its sum must be the same
as this of x. To do this I assume that the distribution of the y and x is the
same and thus multiply the sum of x with the shares of y. An example:
*------------------------------------------------------

sysuse abdata , clear
keep wL1 nL1
drop if missing(wL1,
nL1)
ren wL1 y
ren nL1 x
egen t_y=total(y)
gen y_share=y/t_y
egen t_x=total(x)
gen newx = y_share*t_x
egen
t_newx=total(newx)

su t_x t_newx
*------------------------------------------------------

I want to take into account whether x is positive (more important) or negative
(less important) and my question is how I can do this.
Thank you