Announcement

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

  • Getting a "Operation timed out" error when using 'forvalues' command.

    Hi all,

    I am unable to run a 'forvalues' command, and I am unsure as to why I am receiving the error "Operation timed Out".

    Please see the code I am running below.

    In sum, I am trying to loop over a large number of files in a folder (approx. 2000 files). I have limited the number of values to '5' to be able to test my code. However, once the code works, I will change the '5' to '2000' in the forvalues loop.


    **** Stat Code ****

    * save a copy so that we can load each observation in the loop below
    tempfile files
    save "files", replace

    * loop over each file and input each csv file into temporary datasets.
    forvalues i = 1/5 {

    use "files" in `i', clear
    global f = dirname + "/" + filename
    global d = filename

    clear
    import delimited using "$f", varnames(1) numericcols(_all)

    gen temp_cel = ((temp-32)*5)/9
    gen dewp_cel = ((dewp-32)*5)/9
    gen RH = (exp(17.625*(dewp_cel/(dewp_cel/(243.04+dewp_cel)))))/(exp(17.625*(temp_cel/(temp_cel/(243.04+temp_cel)))))

    keep(date latitude longitude wdsp temp prcp RH)

    save "$path/Data/dta_Temperature_df1/$d.dta", replace
    }

    **** end of state code ****

    Thanks!

  • #2
    I can't claim to know exactly what is going wrong. But the only operations in your code that I see as susceptible to timing out are the -import delimited- and -save- operations. Even that would be unusual if you are reading from and writing to a local drive. If this is happening on a local drive, it may suggest a bad segment that your OS needs to take out of action, or impending disk drive failure.

    Are you working over a network? If so, it may be that traffic on your network is interfering with your ability to access the files you need to work with. The first solution, if this is the problem, would be to try again at a time when the network is less busy, or request the IT administrator to give you a higher priority on the network.

    Other Forum members may have additional ideas and should chime in with those.

    Comment


    • #3
      Hello Garreth,

      You may find try helpful, ssc install try and see help try for details. The basic use case is:
      Code:
      try: import delimited ...
      try: save ...

      Comment

      Working...
      X