Notice: On April 23, 2014, Statalist moved from an email list to a forum, based at statalist.org.

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

From |
"Martin Weiss" <martin.weiss1@gmx.de> |

To |
<statalist@hsphsun2.harvard.edu> |

Subject |
st: AW: Number of a subset of variables in local |

Date |
Thu, 19 Aug 2010 15:11:13 +0200 |

<> ************* sysuse auto, clear d t*, varlist local myvars=r(varlist) local mycount: list sizeof myvars di in r "Variables found: `myvars', number of vars in there: " `mycount' ************* HTH Martin -----Ursprüngliche Nachricht----- Von: owner-statalist@hsphsun2.harvard.edu [mailto:owner-statalist@hsphsun2.harvard.edu] Im Auftrag von Trelle Sven Gesendet: Donnerstag, 19. August 2010 15:04 An: statalist@hsphsun2.harvard.edu Betreff: st: Number of a subset of variables in local Dear all, I have a dataset with several variables all starting with the same name plus sequential numbers at the end (e.g. name1, name2, name3, ...). In addition, there are several other variables. I want to put the number of variables starting with "name" in a local. Originally I thought I can use describe name* But apparently, the describe command puts the number of variables of the whole dataset in r(k) and not just the number of variables specificied after the command. This is my workaround: * example starts use datatset.dta, clear keep name* qui describe local n = r(k) use datatset.dta, clear * Example ends Does anybody know whether there is a more elegant way i.e. can I avoid loading the dataset twice? Thanks for your help Sven * * 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/ * * 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: Number of a subset of variables in local***From:*"Trelle Sven" <strelle@ctu.unibe.ch>

**References**:**st: Number of a subset of variables in local***From:*"Trelle Sven" <strelle@ctu.unibe.ch>

- Prev by Date:
**Re: st: Number of a subset of variables in local** - Next by Date:
**st: RE: Number of a subset of variables in local** - Previous by thread:
**Re: st: Number of a subset of variables in local** - Next by thread:
**st: RE: Number of a subset of variables in local** - Index(es):