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

From |
"Mingfeng Lin" <mingfeng.lin@gmail.com> |

To |
statalist@hsphsun2.harvard.edu |

Subject |
st: counting the number of times a string appears in a string variable? |

Date |
Tue, 4 Nov 2008 21:42:28 -0500 |

Greetings, I looked through the list of string functions but couldn't find one that fits the bill. Suppose I have a string variable X, and I would like to generate a new numeric variable Y containing the number of times a certain string appeared in X. For instance X = "johnabc johncd" If I'd like to find the number of times "john" shows up in X, I hope to obtain Y = 2 Is there a function in Stata to do this? Thank you very much for your help! Mingfeng * * 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**:**Re: st: counting the number of times a string appears in a string variable?***From:*Phil Schumm <pschumm@uchicago.edu>

**Re: st: counting the number of times a string appears in a string variable?***From:*"Friedrich Huebler" <fhuebler@gmail.com>

- Prev by Date:
**Re: st: RE: upgrading to v10: do-file won't load** - Next by Date:
**st: Error using svrmodel** - Previous by thread:
**st: testing equality of coefficients across two equations after xtpcse** - Next by thread:
**Re: st: counting the number of times a string appears in a string variable?** - Index(es):

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