Statalist


[Date Prev][Date Next][Thread Prev][Thread Next][Date index][Thread index]

st: compare variables


From   "Stat List" <statlist@gmail.com>
To   <statalist@hsphsun2.harvard.edu>
Subject   st: compare variables
Date   Thu, 30 Aug 2007 01:44:56 -0400

Hi Statalist,

If I have two variables with numeric contents, is there any Stata command to
compare them, and get the maximum into another variables?

Example, comparing (elements by elements) var1 and var2, and then creating
var3=max(var1, var2)

Var1 var2 var3
12	32	32
21	12	21
3	32	32
32	12	32
..	..	..

I think  I can write the loop for all observations, but I think that Stata
have this kind of command that I just don't know yet.

Any help? Thanks so much
Stat

*
*   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–2014 StataCorp LP   |   Terms of use   |   Privacy   |   Contact us   |   What's new   |   Site index