Bookmark and Share

Notice: On March 31, it was announced that Statalist is moving from an email list to a forum. The old list will shut down on April 23, and its replacement, statalist.org is already up and running.


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

AW: st: AW: Reference column without knowing variable name?


From   "Martin Weiss" <martin.weiss1@gmx.de>
To   <statalist@hsphsun2.harvard.edu>
Subject   AW: st: AW: Reference column without knowing variable name?
Date   Fri, 5 Mar 2010 14:55:47 +0100

<> 

True! -_N- does indeed refer to the number of rows in the dataset (which is the same for all vars, unlike some spreadsheet software products), so you want -c(k)- as the endpoint, which does refer to the number of columns in the dataset. BTW, the result is the same, but computation is probably 0.01 seconds faster.


*************
ma drop _all
sysuse auto, clear

qui ds, has(type numeric)
forv i=1(3)`=c(k)'{
	loc newvars `newvars' `:word `i' of `r(varlist)''
}

foreach var of local newvars{
	replace `var'=2*`var'
}
*************



HTH
Martin


-----Ursprüngliche Nachricht-----
Von: owner-statalist@hsphsun2.harvard.edu [mailto:owner-statalist@hsphsun2.harvard.edu] Im Auftrag von Andrew Wood
Gesendet: Freitag, 5. März 2010 14:01
An: statalist@hsphsun2.harvard.edu
Betreff: Re: st: AW: Reference column without knowing variable name?

Thanks, but doesn't _N refer to number of observations in a variable? I've tried this and doesn't quite do what I'm after... any other ideas?

Thanks again

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


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