Statalist


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

Re: st: ST: Is STATA working?


From   Austin Nichols <austinnichols@gmail.com>
To   statalist@hsphsun2.harvard.edu
Subject   Re: st: ST: Is STATA working?
Date   Sun, 13 Sep 2009 10:11:37 -0400

Laura Platchkov <LMP881@bham.ac.uk>:
If you are looping, you can throw out an example every once in a while
to see what is being done, and where you are in the loop.

For example, here is a set of 800 imaginary farms, and a loop that
finds the two states at the nearest state boundary, where every 150
obs a graph is drawn to indicate progress is being made, and we start
with a graph for the first obs so we get some immediate feedback:

clear all
range pid 1 800 800
set seed 123
g farm_Y=32+uniform()*10
g farm_X=-120+uniform()*40
compress
save exfarms

use exfarms, clear
local nf=_N
g double mindist=.
g stateID1=.
g stateID2=.
merge using http://pped.org/stata/usa.dta
local R=6367.44
qui forv i=1/`nf' {
local y1=farm_Y[`i']
local x1=farm_X[`i']
local y2 _Y
local x2 _X
g double L=(`x2'-`x1')*_pi/180
replace L=(`x2'-`x1'-360)*_pi/180 if L<. & L>_pi
replace L=(`x2'-`x1'+360)*_pi/180 if L<-_pi
local t1 acos(sin(`y2'*_pi/180)*sin(`y1'*_pi/180)
g double d=`t1'+cos(`y2'*_pi/180)*cos(`y1'*_pi/180)*cos(L))*`R'
su d, meanonly
replace mindist=r(min) in `i'
su _ID if d==r(min), meanonly
loc i1=r(min)
loc i2=r(max)
if `i1'==`i2' {
 su d if _ID!=`i1', meanonly
 su _ID if d==r(min) & _ID!=`i1', meanonly
 loc i2=r(min)
}
replace stateID1=`i1' in `i'
replace stateID2=`i2' in `i'
loc s `"sc _Y _X if inlist(_ID,`i1',`i2'),mc(gs12)"'
loc s `"`s'||scatteri `y1' `x1',msiz(large) name(ex`i')"'
if mod(`i',150)==1 `s'
drop L d
}
drop if _m==2
drop _m _ID _X _Y


On Sat, Sep 12, 2009 at 1:53 PM, Laura Platchkov <LMP881@bham.ac.uk> wrote:
> Hi, I am running a huge command wiht more than 1'000'000 operations to do by STATA, and I wa just wondering how I could assure myself that it is really computing some results and I am not waiting for Godot in front of my computer ....?
*
*   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