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

From |
Fred Wolfe <[email protected]> |

To |
[email protected] |

Subject |
RE: st: STATA Vs. SAS |

Date |
Wed, 27 Nov 2002 15:05:24 -0600 |

In general, this type of code often works very well:Yes, that's what I meant. In my simple example, using the Stata alternative isn't such a problem, but often I want to apply a subcondition to only some values. So, e.g., if x=0 then y=1; else if 1 < x < 10 then do; <other sas commands>; end; else if 11 < x < 20 then do; <other sas commands>; end; It's difficult and tedious to have to write the multiple levels of conditions if the program is going to evaluate every if statement.

gen y = 1 if x == 0

some command if inrange(x,2,9)

... more .. if needed

some command if inrange(x,12,19)

... more .. if needed

Practically, if the if condition is complicated one often makes a new variable or local macro, as in

gen newvar = cond(x == 1 & age >27 & date >mdy(01,01,2002),1,0)

then just using - if newvar- for the if condition.

Fred Wolfe

---------------------------------------------------------------------------- ------------------------

Fred Wolfe Tel (316) 263-2125

National Data Bank for Rheumatic Diseases Fax (316) 263-0761

Wichita, Kansas [email protected]

---------------------------------------------------------------------------- -------------------------

*

* For searches and help try:

* http://www.stata.com/support/faqs/res/findit.html

* http://www.stata.com/support/statalist/faq

* http://www.ats.ucla.edu/stat/stata/

**Follow-Ups**:**RE: st: STATA Vs. SAS***From:*"Nick Cox" <[email protected]>

**References**:**RE: st: STATA Vs. SAS***From:*"Nick Winter" <[email protected]>

**RE: st: STATA Vs. SAS***From:*Richard Herrell <[email protected]>

- Prev by Date:
**RE: st: STATA Vs. SAS** - Next by Date:
**RE: st: STATA Vs. SAS** - Previous by thread:
**RE: st: STATA Vs. SAS** - Next by thread:
**RE: st: STATA Vs. SAS** - Index(es):

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