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]
Re: st: RE: Loop question
From
Alberto R Osella <[email protected]>
To
[email protected]
Subject
Re: st: RE: Loop question
Date
Tue, 08 Feb 2011 11:19:00 +0100
Thank you Nick. You are right. I found the mistake and now the loop runs
well.
Thank you again.
Alberto
Alberto R. Osella, MD, PhD
Laboratorio di Epidemiologia e Biostatistica
IRCCS Saverio de Bellis
Via Turi, 27
70013 Castellana Grotte (BA)
Italia
Tel: +39 0804994655
Fax: +39 0804994650
e-mail: [email protected]
Il 08/02/2011 11:06, Nick Cox ha scritto:
Strictly, I don't know that P_B4_cut is a variable. It might be a variable; it might be a scalar; it might not exist. There is no way to tell from this posting. But whatever the story, -xtile- won't run because it needs a varname.
Nick
[email protected]
Nick Cox
Stata is telling you the problem. It is nothing to do with the loop as such, but a problem with the syntax of -xtile-.
The -cutpoint()- option expects a variable.
P_R1 - P_B4_cut is not a variable; it is an expression, specifically the difference between two variables. Therefore, you must create a variable holding this difference before you enter the loop.
Alberto R Osella
after a factor analysis (pca) I'd want to create categorical variables
by using a loop. But I have some troubles. Here the code I'm using
predict P_R1 P_R2 P_R3 P_R4, regression
predict P_B1 P_B2 P_B3 P_B4, bartlett
foreach x of var P_R1-P_B4 {
pctile q_`x'_c= `x' if caso_ctrol0==0& P_R1-P_B4<., nq(5)
tab2 `x' caso_ctrol0
xtile `x'_q=`x', cutpoint( P_R1-P_B4_cut)
tab2 `x'_q caso_ctrol0
}
and this is the error:
variable P_B4_cut not found
in option cutpoints()
r(111)
I'm using Stata 11.1 on windows 7.
*
* 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/