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]
AW: st: AW: Reference column without knowing variable name?
From
"Martin Weiss" <[email protected]>
To
<[email protected]>
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: [email protected] [mailto:[email protected]] Im Auftrag von Andrew Wood
Gesendet: Freitag, 5. März 2010 14:01
An: [email protected]
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/