Announcement

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

  • Macro Data Replacement

    Hello,
    I am attempting to use the results of two count if functions in one calculation by storing the result of the first in a local macro. Here is an example of what I am attempting to do:

    Code:
        count if PROCEDURE_DATE <18993
        local tot_date "`r(N)'"
        count if PROCEDURE_DATE <18993 & DOSE2==.
        display "Time Range: " %td 18638 " - " %td 18993
        display "% missing dose info: " (r(N)/`tot_date')*100 "%"
    However, when I run the second count if, it replaces the value stored in the macro tot_date with the new value of r(N). How can I save the first value of r(N) into a macro in a way that it will not be overwritten when I run count if for a second time? Or is there a better method than using macros to save the results of the first count if?

  • #2
    Code:
    count if PROCEDURE_DATE <18993
    local tot_date = "`r(N)'"
    count if PROCEDURE_DATE <18993 & DOSE2==.
    display "Time Range: " %td 18638 " - " %td 18993
    display "% missing dose info: " (r(N)/`tot_date')*100 "%"
    ---------------------------------
    Maarten L. Buis
    University of Konstanz
    Department of history and sociology
    box 40
    78457 Konstanz
    Germany
    http://www.maartenbuis.nl
    ---------------------------------

    Comment


    • #3
      Thank you very much! This worked.

      Comment

      Working...
      X