And Eva. You guys were so helpful. Thank you.
On 25/03/2008, Eva Poen <[email protected]> wrote:
> Libby,
>
> here are two ways to do it.
>
> 1.
> qui ds *
> foreach x of varlist `=r(varlist)' {
>
> capture confirm string variable `x'
>
> if !_rc {
> do string things
> }
> else {
> do numeric things
> }
> }
>
> 2.
> qui ds *, has(type string)
> foreach x of varlist `=r(varlist)' {
> do string things
> }
>
> qui ds *, has(type numeric)
> foreach x of varlist `=r(varlist)' {
> do numeric things
> }
>
>
>
> Eva
>
>
> 2008/3/25, Libby Hemphill <[email protected]>:
>
> > Hi,
> >
> > I'm wondering if there's a way to loop through all my variables and
> > perform some action only on those that are numeric. Is there a way to
> > check for the type of the variable before doing something? Like
> >
> > for each variable
> > if string, next
> > else do X
> > end for
> >
> > Thanks!
> >
>
> > --
> > Libby Hemphill
> > Doctoral Candidate
> > School of Information
> > University of Michigan
> > http://www.libbyh.com
> > *
>
> > * 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/
> >
> *
> * 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/
>
--
Libby Hemphill
Doctoral Candidate
School of Information
University of Michigan
http://www.libbyh.com
*
* 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/