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

RE: st: question on cond( )

From   "Nick Cox" <>
To   <>
Subject   RE: st: question on cond( )
Date   Fri, 29 Feb 2008 11:10:43 -0000

That's a dopey example of mine. If you want to map 1 -> 1, 2 -> 2, 3 ->
3, everything else -> 4, you can 
do it more concisely. The point is just to mention nesting. 

Nick Cox

Your last question is about intention -- what was in the mind of the
program designers -- and 
is perhaps best answered by StataCorp. Oddly enough, I've never used the
four argument case that
I can recall. Although some dislike the usage, nesting of -cond(,)- lets
you handle four or more
branches, and I find that more congenial, e.g.  

cond(x == 1, 1, cond(x == 2, 2, cond(x == 3, 3, 4))) 

Naturally there are many other ways to achieve similar results. 


Visintainer, Paul


Thanks for the coding suggestions.  This is exactly what I was looking
for--especially for the multiple variables.  And, Nick (Winter), thanks
for the explanation for cond().  

One question: was it the intention of the 4-level cond() to code for
missings or is there some other application for it?

*   For searches and help try:

© Copyright 1996–2017 StataCorp LLC   |   Terms of use   |   Privacy   |   Contact us   |   What's new   |   Site index