Hello Carlo,
cond would not be useful cos it can do ONLY 2 conditions. I want to be
able to use it in MANY conditions. Is there a SUPER cond which can do
that ?
Thank you,
Ashim
On Thu, Nov 13, 2008 at 2:27 PM, Carlo Lazzaro
<[email protected]> wrote:
> Dear Ashim,
> would - help cond() - be useful for your research purposes?
>
> Kind Regards,
> Carlo
> -----Messaggio originale-----
> Da: [email protected]
> [mailto:[email protected]] Per conto di Ashim Kapoor
> Inviato: giovedì 13 novembre 2008 8.56
> A: [email protected]
> Oggetto: st: if and if
>
> Hello everyone,
>
> I realize that there are 2 kinds if's in Stata.
>
> Type 1 : would be something like replace j = 2 if k==2
> here the replace in j would happen ONLY in the corresponding
> observation of k. THIS IS WHAT I WANT.
>
>
> Type 2 : the programming if something like
>
> local j
>
> if `j'==2 {
>
> do something.
>
> }
>
> **************************************************************
>
> I guess I want to do something which is in between the above 2.
>
> I want to say the following : --
>
> replace j=2 if k==2
> replace m=2 if k==2
> replace n=2 if k==2
>
> in ONE shot.
>
> so I try : -
> ************************************** Block A
> if k==2 {
> replace j=2
> replace m=2
> replace n=2
> }
> *********************************************
> This does not work. Because k==2 would mean k==2 in ALL observations.
> While I mean to say make j / m / n = 2 in those observations where k
> is 2.
>
> How do I do this in a quick manner in Block A ?
>
> I understand that I can always do :-
>
> foreach var of j m n {
> replace `var'=2 if k==2
> }
>
> But is there a better way ?
>
> The reason I want this is the following : -
>
> I want
>
> if k==2 {
> replace j=1
> replace m=5
> replace n=89
> }
>
> so the above method fails as I do not have the SAME value 2 to be put
> in each of j / m /n.
>
> Any slick way of doing this ?
>
> Thank you,
> Ashim
> *
> * 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/
>
>
>
> *
> * 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/
>
*
* 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/