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

From |
"Ashim Kapoor" <ashimkapoor@gmail.com> |

To |
statalist@hsphsun2.harvard.edu |

Subject |
Re: R: st: R: if and if |

Date |
Thu, 13 Nov 2008 15:43:16 +0530 |

Thank you Carlo. Ashim. On Thu, Nov 13, 2008 at 3:35 PM, Carlo Lazzaro <carlo.lazzaro@tiscalinet.it> wrote: > Dear Ashim, > unfortunately I am not aware of a SUPER cond Stata routine and -foreach- is > still my best bet. > > Sorry I cannot be more helpful about this interesting query. > > Kind Regards, > Carlo > -----Messaggio originale----- > Da: owner-statalist@hsphsun2.harvard.edu > [mailto:owner-statalist@hsphsun2.harvard.edu] Per conto di Ashim Kapoor > Inviato: giovedì 13 novembre 2008 10.52 > A: statalist@hsphsun2.harvard.edu > Oggetto: Re: st: R: if and if > > 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 > <carlo.lazzaro@tiscalinet.it> wrote: >> Dear Ashim, >> would - help cond() - be useful for your research purposes? >> >> Kind Regards, >> Carlo >> -----Messaggio originale----- >> Da: owner-statalist@hsphsun2.harvard.edu >> [mailto:owner-statalist@hsphsun2.harvard.edu] Per conto di Ashim Kapoor >> Inviato: giovedì 13 novembre 2008 8.56 >> A: statalist@hsphsun2.harvard.edu >> 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/ > > > > * > * 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/

**References**:**Re: st: R: if and if***From:*"Ashim Kapoor" <ashimkapoor@gmail.com>

**R: st: R: if and if***From:*"Carlo Lazzaro" <carlo.lazzaro@tiscalinet.it>

- Prev by Date:
**R: st: R: if and if** - Next by Date:
**Re: st: if and if** - Previous by thread:
**R: st: R: if and if** - Next by thread:
**Re: st: R: if and if** - Index(es):

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