Notice: On April 23, 2014, Statalist moved from an email list to a forum, based at statalist.org.
From | Alison El Ayadi <aelayadi@gmail.com> |
To | statalist@hsphsun2.harvard.edu |
Subject | Re: st: RE: identifying highest number of consecutive variables where answer is consistent across observation |
Date | Wed, 26 Feb 2014 20:03:44 -0800 |
Dear Statalisters - I have been using the below code to identify the runs of consecutive variables where answer is consistent across observations (my thanks to Joe Canner) - gen run=0 replace run_15=0 forvalues x=1/93 { local y=`x'+1 replace run=run+1 if q`x'==q`y' & !mi(q`x') replace run=0 if q`x'!=q`y' & run_15==0 replace run_15=1 if run==14 } I now am in the situation where I have received an updated dataset that excludes certain variables (q4 q33 and others). I wonder if there is an easy way to tell this program to exclude certain values but still run consecutively across those variables that are present? Thank you! Alison * * 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/