Bookmark and Share

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


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

st: mata conditional operator element-by-element?


From   László Sándor <[email protected]>
To   [email protected]
Subject   st: mata conditional operator element-by-element?
Date   Fri, 27 Apr 2012 14:24:16 -0400

Hi,

I checked the help for -m2_op_conditional- on up-to-date Stata 12.1 MP
for mac, and it looks like the conditional operator only works for
"general conditions", i.e. scalars, not element-by-element in vectors.
Much of my code did use -st_select-, but I thought some parts could
still be cleaner and/or more efficient if I could use something like
the conditional operator for vectors (as Matlab does allow). Please
let me know if you have good advice how to get from this

(t:/psc:^2 + (-1:*t:+1):/(-1:+psc):^2))

to something like this

(t == 1 ? psc : psc:-1)^2

[Yes, I would immediately see a problem with this syntax a colon
operator confusing the conditional operator…]

Thanks!

Laszlo

*
*   For searches and help try:
*   http://www.stata.com/help.cgi?search
*   http://www.stata.com/support/statalist/faq
*   http://www.ats.ucla.edu/stat/stata/


© Copyright 1996–2018 StataCorp LLC   |   Terms of use   |   Privacy   |   Contact us   |   Site index