Announcement

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

  • How to specify an action over a specific data range use foreach or forval

    I'm pretty new to Stata and have been struggling with something that I know shouldn't be this difficult. I am trying to reverse geocode a dataset of 14,000 observations, but can only evaluate 2,500 observations per day for free. I already did the first 2,500 and am now trying to do the next 2,500. I can't figure out how to write a loop so that the command executes over observations 2,500-5000. Right now, I'm just testing the logic by trying to display the values of variable 'latitude' for observations 2501-2506.

    This is what I have been trying:
    Code:
    foreach i of list latitude 2501/2506 {
    2. di `i'
    3. }

    And I'm getting an invalid syntax error.

    I also tried
    Code:
    foreach i in latitude 2501/2506 {
    2. di latitude
    3. }

    For this one, it returns the latitude value of observation 1 twice.

    Any suggestions would be greatly appreciated! Thanks!

  • #2
    Duplicate post. Asked and answered (by others) at https://www.statalist.org/forums/for...f-observations.

    Comment

    Working...
    X