Bookmark and Share

Notice: On March 31, it was announced that Statalist is moving from an email list to a forum. The old list will shut down on April 23, and its replacement, is already up and running.

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

st: New variable based on two other variable

From   David Ashcraft <>
To   "" <>
Subject   st: New variable based on two other variable
Date   Sat, 6 Apr 2013 01:52:09 -0700 (PDT)


I want to generate a variable based on two existing variables.

I have two variables : govshr and prishr and the variable I need is to take the value of govshr or prish whichever is greater. 
I tried the following but the result is not what I want
1. gen right=0
2. replace right=govshr if govshr>prishr
3. replace right=prishr if prishr>govshr

What happend it, stata takes both commands (2 & 3) separately so I end up with the results of either (2) or (1). Any help will be highly appreciated.

David Ashcraft
PhD candidate
Bangor University

*   For searches and help try:

© Copyright 1996–2016 StataCorp LP   |   Terms of use   |   Privacy   |   Contact us   |   Site index