Announcement

Collapse
No announcement yet.
X
  • Filter
  • Time
  • Show
Clear All
new posts

  • Keeping and saving dataset for each year from a panel dataset and geonearing each dataset with another dataset in a lop

    I want to create a new dataset for each year from a panel dataset in a loop and then merge each dataset with a geovariable also in a loop. I have written this code but doesn't seem to work well. I'd appreciate your guidance.

    use "$output2\household.dta", clear
    preserve

    forval i =1997/2000 {

    keep if year== `i'
    tempfile household
    save `household'

    use "$output2\Geodata.dta"
    geonear id lat long using `household', neighbors(id lat long) long


    restore, preserve
    }

  • #2
    geonear is from SSC (FAQ Advice #12). When you run this command, you do not save any results. First, show us the exact Stata output and explain what

    but doesn't seem to work well
    means. Better still, provide a sample of both datasets using dataex.

    Comment

    Working...
    X