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?

  • $\begingroup$ 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. $\endgroup$
    – Mike J
    Mar 6, 2021 at 10:29
  • 1
    $\begingroup$ @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 $\endgroup$
    – 1muflon1
    Mar 6, 2021 at 11:55
  • $\begingroup$ @1muflon1 understood. Thanks for letting me know. $\endgroup$
    – Mike J
    Mar 6, 2021 at 22:12
  • 1
    $\begingroup$ How is it not working? What error are you getting and at what line? What exactly is the problem? And what have you tried? $\endgroup$
    – BB King
    Mar 14, 2021 at 1:08


Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

Browse other questions tagged or ask your own question.