<p>I am trying to  generate PMdist`i' variables, using the following codes</p>
<pre><code>display &quot;************** PM10 distances **************&quot;


forval i=1/12599 {
    display &quot;Attempting to compute distance `i'&quot;

    capture geodist latitude longitude latitude`i' longitude`i' [if] [in], generate(PMdist`i')

    capture replace PMdist`i' = . if (PMdist`i' &gt; 257 &amp; !missing(PMdist`i'))

    capture drop latitude`i' longitude`i'
  }
egen PMmindist = rowmin(PMdist1-PMdist12581)

forval i=1/12599 {

    capture drop PMdist`i'
}

</code></pre>
<p>Can anyone tell me why its not working and what is the alternative solution?</p>

CC BY-SA 4.0
2021-03-06T10:29:25.350Z
I think this question is out of scope for this forum.  Needs to be related to economics.  Whats posted is computer code not related to econ.
Mike J
CC BY-SA 4.0
2021-03-06T11:55:50.220Z
@MikeJ actually according the help center: "Software questions: Questions related to software used in economics and econometrics, are on-topic here." Stata is used in economics - perhaps we should narrow the scope of site a bit (I would not be opposed to change it to 'software used in economics and econometrics applied to economic problem'  or something else that narrows it down - if you think it is good idea rise the issue on meta), but as our scope is defined now it is on-topic
1muflon1
CC BY-SA 4.0
2021-03-06T22:12:43.900Z
@1muflon1  understood.   Thanks for letting me know.
Mike J
CC BY-SA 4.0
2021-03-14T01:08:25.400Z
How is it not working? What error are  you getting and at what line? What exactly is the problem? And what have you tried?
BB King
<stata>
generating a variable
Jui Sen
# generating a variable

(Asked by: username_0 on 2021-03-06)

I am trying to  generate PMdist`i' variables, using the following codes
display "************** PM10 distances **************"


forval i=1/12599 {
    display "Attempting to compute distance `i'"

    capture geodist latitude longitude latitude`i' longitude`i' [if] [in], generate(PMdist`i')

    capture replace PMdist`i' = . if (PMdist`i' > 257 & !missing(PMdist`i'))

    capture drop latitude`i' longitude`i'
  }
egen PMmindist = rowmin(PMdist1-PMdist12581)

forval i=1/12599 {

    capture drop PMdist`i'
}


Can anyone tell me why its not working and what is the alternative solution?

**Tags:** stata
> **Comments:**
> **username_1**: I think this question is out of scope for this forum.  Needs to be related to economics.  Whats posted is computer code not related to econ.  
> **username_2**: @MikeJ actually according the help center: "Software questions: Questions related to software used in economics and econometrics, are on-topic here." Stata is used in economics - perhaps we should narrow the scope of site a bit (I would not be opposed to change it to 'software used in economics and econometrics applied to economic problem'  or something else that narrows it down - if you think it is good idea rise the issue on meta), but as our scope is defined now it is on-topic  
> **username_1**: @1muflon1  understood.   Thanks for letting me know.  
> **username_3**: How is it not working? What error are  you getting and at what line? What exactly is the problem? And what have you tried?  

---

## 0 answers

