Announcement

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

  • Problem: Putexcel continuously saving - how can I resolve this?

    Hello,
    I am using STATA 15.0 and using .do files we are creating to call on a .ado file to format .csv data appears to be continuously saving..... making it quite slow!
    How can I recode my .ado file so it wont do this?
    I have spent some hours trying to work on a solution to this via Google and reading masses of examples of code, but am not getting very far.
    Appreciate any help you can provide
    Andy

    .ado code

    program define tab2date_to_excel

    tabulate `1' `2', matcell(categories) matrow(rows)

    cap putexcel set "`3'", modify sheet("`4'")

    putexcel A1=("`1'" + " by " + "`2'")

    local categories = colsof(categories)
    local rows = rowsof(rows)

    forvalues j = 1/`categories' {
    local col = char(65 + `j')
    local row = 2
    local running_total = 0
    putexcel `col'1=("`j'")
    forvalues i = 1/`rows' {

    local var1value = string(rows[`i',1],"`5'")
    local n = categories[`i',`j']
    local running_total = `running_total' + `n'
    putexcel A`row'=("`var1value'") `col'`row'=(`n')
    local row = `row' + 1
    }
    putexcel A`row'=("Total") `col'`row'=(`running_total')
    }

    end

  • #2
    To answer our own question, you can use the "quietly" command - now our data process is really quick - 1 second versus 4.. when workign with larger data sets [we are using 3,000 obs] it should be much better now.
    code example:

    program define tab2date_to_excel

    tabulate `1' `2', matcell(categories) matrow(rows)

    cap putexcel set "`3'", modify sheet("`4'")

    qui putexcel A1=("`1'" + " by " + "`2'")

    local categories = colsof(categories)
    local rows = rowsof(rows)

    forvalues j = 1/`categories' {
    local col = char(65 + `j')
    local row = 2
    local running_total = 0
    qui putexcel `col'1=("`j'")
    forvalues i = 1/`rows' {

    local var1value = string(rows[`i',1],"`5'")
    local n = categories[`i',`j']
    local running_total = `running_total' + `n'
    putexcel A`row'=("`var1value'") `col'`row'=(`n')
    local row = `row' + 1
    }
    qui putexcel A`row'=("Total") `col'`row'=(`running_total')
    }

    end

    Comment


    • #3
      Hi ‘Clincal Epidemiology’,

      I believe this is not a true name. Please read the FAQ. There you will find the recommendation to you name and family name.

      Furthermore, I gather thr best approach is each member having a respective register.

      Best regards,

      Marcos

      Comment

      Working...
      X