Announcement

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

  • Read dta file from line n to end

    Using this excellent advise, I am running a loop to read in a 60GB dta file and save it in chunks (after some data preprocessing). Unfortunately, I do not know the total number of observations and so the `use` command does not execute when asking to read in more data than is avilable:
    ```Stata
    use `usevars' in 210000001/220000000 using "a_large_dta_file.dta", clear
    ```
    The dataset appears to contain less than 220000000 observations, but I do not know how many. I am looking for and `endoffile` operator or something in that spirit to circumvent this problem. Manually I verified that at least 210001001 exist, but this won't help much.

    ---
    Crossposted on Stackoverflow (https://stackoverflow.com/questions/...-line-n-to-end)



  • #2
    Try

    Code:
    describe using "a_large_dta_file.dta" , short
    return list
    local N = r(N)
    to get the number of observations into local macro N.

    Best
    Daniel

    Comment

    Working...
    X