Stata The Stata listserver
[Date Prev][Date Next][Thread Prev][Thread Next][Date index][Thread index]

st: RE: Capturing the data type of a variable


From   "Nick Cox" <n.j.cox@durham.ac.uk>
To   <statalist@hsphsun2.harvard.edu>
Subject   st: RE: Capturing the data type of a variable
Date   Mon, 8 Mar 2004 17:09:55 -0000

Yes. 

local type : type <varname> 

For your purposes, you might want to go straight
to -ds-. 

. ds, has(type 10/244) 

names all such variables, after which you can loop 

. foreach v in `r(varlist)' { 
	... 

To do this, you need Stata 8 updated after 17 June 2003. 

Nick 
n.j.cox@durham.ac.uk 

PAUL HEWETT 
> 
> I am looking to loop through each of the variables in my 
> dataset and manipulate variables that are of data type str10 
> or more. Is there any way I can capture the data type of a 
> variable? Neither describe or codebook seem to have return 
> codes r( ) that would serve this purpose. If I can capture 
> the variable type as a string, e.g., "byte", "str5", 
> "integer" it would easy from there.

*
*   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/



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