Bookmark and Share

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]

st: RE: Loop question


From   Nick Cox <[email protected]>
To   "'[email protected]'" <[email protected]>
Subject   st: RE: Loop question
Date   Tue, 8 Feb 2011 10:06:28 +0000

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/


© Copyright 1996–2018 StataCorp LLC   |   Terms of use   |   Privacy   |   Contact us   |   Site index