Statalist


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

Re: st: RE: Capture inside a forvalues loop


From   Conor Sontag <[email protected]>
To   [email protected]
Subject   Re: st: RE: Capture inside a forvalues loop
Date   Thu, 24 Sep 2009 14:30:21 -0400

I may not have been clear enough in my explanation of what I was trying to do.

I'm looping through the whole dataset, but my values for j are only
from 1 to r(max).

Previously, I parsed one of my string variables and created variable
advindividual1 through r(max).  So, I am not able to use the -in-
qualifier inside of my forvalues loop since I'm using the values of
duplicate to tell what to replace advisor with.

Thanks,
Conor

On Thu, Sep 24, 2009 at 1:53 PM, Martin Weiss <[email protected]> wrote:
>
> <>
>
> While we are being picky: If all you want is the max and no display of any
> kind, you might as well code
>
> **************
> sum duplicate, mean
> forvalues j = 1/`r(max)' {
> **************
>
> They say it is faster than a normal -summarize-...
>
> Also see Nick`s http://www.stata-journal.com/article.html?article=st0135
>
>
> HTH
> Martin
>
>
> -----Original Message-----
> From: [email protected]
> [mailto:[email protected]] On Behalf Of Conor Sontag
> Sent: Donnerstag, 24. September 2009 19:26
> To: [email protected]
> 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/
>



*
*   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–2024 StataCorp LLC   |   Terms of use   |   Privacy   |   Contact us   |   What's new   |   Site index