Notice: On April 23, 2014, Statalist moved from an email list to a forum, based at statalist.org.
From | Joerg Luedicke <joerg.luedicke@gmail.com> |
To | statalist@hsphsun2.harvard.edu |
Subject | Re: st: Conditional Counter |
Date | Mon, 15 Oct 2012 08:42:09 -0500 |
One possibility would be to convert your variable into a string variable (if it isnt' one already), then create an indicator for appearances of sevens: *-------------------------------------- input nnaadd 1234 3456 6543 7777 777 77 1267 end tostring nnaadd, g(strnnaadd) gen seven=strmatch(strnnaadd, "*7*") tab seven *-------------------------------------- Joerg On Mon, Oct 15, 2012 at 8:28 AM, Gonzalo DURAN SANHUEZA <giduran@puc.cl> wrote: > Dear Statalist-Member, I have a variable it contains numbers: > > nnaadd > 1234 > 3456 > 6543 > 7777 > 777 > 77 > 1267 > ... > > I need to ask stata to count the number of observations that have at > least one 7.. > Thanks! > > > G > * > * For searches and help try: > * http://www.stata.com/help.cgi?search > * http://www.stata.com/support/faqs/resources/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/faqs/resources/statalist-faq/ * http://www.ats.ucla.edu/stat/stata/