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

From |
Linn Renée Naper <linn.naper@ecgroup.no> |

To |
<statalist@hsphsun2.harvard.edu> |

Subject |
st: RE: RE: using if sentences in Stata |

Date |
Thu, 27 Nov 2008 20:04:48 +0100 |

I've tried and it really doesn't matter... I get the same result. -----Opprinnelig melding----- Fra: owner-statalist@hsphsun2.harvard.edu [mailto:owner-statalist@hsphsun2.harvard.edu] På vegne av Martin Weiss Sendt: 27. november 2008 18:20 Til: statalist@hsphsun2.harvard.edu Emne: st: RE: using if sentences in Stata Line for the server... First impression: Are you sure the first line " if shift==-1 {{" needs two curlies? I cannot figure out what the second one is doing... Try your luck without it and report back to the list. HTH Martin -----Original Message----- From: owner-statalist@hsphsun2.harvard.edu [mailto:owner-statalist@hsphsun2.harvard.edu] On Behalf Of Linn Renée Naper Sent: Thursday, November 27, 2008 6:12 PM To: statalist@hsphsun2.harvard.edu Subject: st: using if sentences in Stata Hi I am trying to program a "double if-sentence" in Stata. Is this possible? And what do I do wrong here? Here is what I write. The results is that Stata only performs the commands after the second "else": replace flow=`cable_cap'. if shift==-1 {{ if (flow[_n-1] + `cap')<`add' { replace flow= (-1*`cap') } else { replace flow=flow[_n-1]-`add' } } else { if (flow[_n-1] - `cap')>`add' { replace flow=`cap' } else { replace flow=flow[_n-1]+`add' } } I thus try to write a command where the executed command if the result (if shift==-1) is true also includes an if-formulation, and the same with the executed command in the case where the result of the initial criterion is false. If the shift value is -1, what I do with the variable flow depends on whether the sum (flow[_n-1]+`cap') is larger or smaller than the value given in `add'. Similarly, if the shift variable isn't -1 but 1, what I do with flow depends on the sum (flow[_n-1]-`cap') and whether this sum is smaller or larger than the value given by `add'. I appreciate any suggestions on how this command should best be writte. Thanks! Linn * * 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**:**st: using if sentences in Stata***From:*Linn Renée Naper <linn.naper@ecgroup.no>

**st: RE: using if sentences in Stata***From:*"Martin Weiss" <martin.weiss1@gmx.de>

- Prev by Date:
**st: re: double if-sentences in Stata** - Next by Date:
**st: re: if-sentences in Stata** - Previous by thread:
**st: RE: using if sentences in Stata** - Next by thread:
**Re: st: using if sentences in Stata** - Index(es):

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