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

From |
Dan Blanchette <dan.blanchette@duke.edu> |

To |
statalist@hsphsun2.harvard.edu |

Subject |
st: New package -ifwins- "if wins!" on SSC to subset data by "if" exp first then "in" range |

Date |
Wed, 18 Mar 2009 10:33:24 -0400 (EDT) |

Dear Statalist Members, Thanks to Kit Baum, a new package -ifwins- is now available for download on SSC. Description -ifwins- is a prefix command that runs most any Stata command that does not modify the dataset in memory (e.g. generate, replace, etc.). -ifwins- will have "if" subset the dataset before "in" subsets the dataset. This is the opposite of what happens when both "if" and "in" are used in the same Stata command. For example, the following code will first subset the dataset to the first 10 observations and then subset the dataset to the specified condition: . sysuse auto . list if foreign == 1 in 1/10 Since the auto.dta dataset is sorted by the variable foreign, the above code will

before the other one does. If you want to run a Stata command on a certain number of observations when a certain condition exists, you would have to: . preserve . keep if foreign == 1 . list in 1/10 make turn weight . restore or use -ifwins- as a prefix to the desired Stata command: . ifwins if foreign == 1 in 1/10 : list make turn weight The above will list the first 10 observations of when the variable foreign is equal to 1 (one). So now "if" wins!...but "in" is still helpful. To install -ifwins-: . ssc install ifwins Let me know if you have any questions. Thanks to Roy Wada for helping me better document -ifwins-. Dan Blanchette Research Associate Center of Entrepreneurship and Innovation Duke University's Fuqua School of Business dan.blanchette@duke.edu * * 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/

**Follow-Ups**:**st: RE: New package -ifwins- "if wins!" on SSC to subset data by "if" exp first then "in" range***From:*"Nick Cox" <n.j.cox@durham.ac.uk>

- Prev by Date:
**RE: st: Clustered Data Format** - Next by Date:
**st: Does Stata have an "exact likelihood approach " to estimate the variance of a proportion?** - Previous by thread:
**st: draw a sample from variables and incidence rates** - Next by thread:
**st: RE: New package -ifwins- "if wins!" on SSC to subset data by "if" exp first then "in" range** - Index(es):

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