Statalist


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

st: RE: Capture inside a forvalues loop


From   "Martin Weiss" <martin.weiss1@gmx.de>
To   <statalist@hsphsun2.harvard.edu>
Subject   st: RE: Capture inside a forvalues loop
Date   Thu, 24 Sep 2009 19:47:51 +0200

<>

**************
clear*
inp x
1
2
2
2
end
gen error=0
forv i=1/4{
capt assert x==1 in `i'
di in red _rc
replace error=_rc in `i'
}
l
**************


HTH
Martin


-----Original Message-----
From: owner-statalist@hsphsun2.harvard.edu
[mailto:owner-statalist@hsphsun2.harvard.edu] On Behalf Of Conor Sontag
Sent: Donnerstag, 24. September 2009 19:26
To: statalist@hsphsun2.harvard.edu
Subject: st: Capture inside a forvalues loop

I have an error inside of my for values loop which is inconsequential
to my results, but i would like to log it in another variable so I can
later look at the data set and see where the error occured.  What I
have now is:

*****
quietly sum duplicate
forvalues j = 1/`r(max)' {
capture replace advisor = advisorindividual`j' if duplicate == `j'
}

I have tried a couple of different ways, but I'm not sure how I can
create a variable "error" which will displays zeros in each row where
the error did not occur, and display the error _rc in the rows that it
did occur.

Thanks,
Conor
*
*   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   |   What's new   |   Site index