Announcement

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

  • Calculation of directly standardized rates "distrate" or "dstdize" commands

    Hello,

    First of all I dont know if this is the proper site to publish this, correct me if its not.

    Need some help:

    I'd used the "distrate" command on a database "DATA.dta" before.

    Done the cleaning on the database and then I modified the "pop.dta" file in which i had the persons-year since the catchment area was modified.

    The original code was:
    Code:
     
     distrate cases pop using pop.dta, standstrata(age_grp) popstand(pop) by(year sex) format(%8.1f) mult(100000)
    the results were good expressed this way
    Code:
    | year sex cases N crude rateadj lb_gam ub_gam se_gam |
    Did it twice with 2 different "pop.dta" and "pop2.dta" since i needed it with both.

    The code was saved on the do-file

    Now the issue im having is that i try to run the code and it says that

    Code:
    varibale pop not found
    r(111);
    Need help: tried using old data base, tried making a new pop dta file for the person-years and nothing.

    thanks for your help.

  • #2
    You say that you had some code that worked fine and then -basically from one day to the other- it stopped working. And from what I understand from your post, you say that nothing changed. Not in the data, not in the do-file, not in the version of -distrate- (from SSC/SJ)...

    I'm not really sure how we're supposed to help you.

    Could you share the data (using -dataex-, see FAQ 12.2)?

    Comment


    • #3
      Im sorry, didnt explain myself well.

      I am trying to do Age Standardized Incidence Rates with "distrate" command.

      My using data looks like this: Sex, Year of incidence, age group and outcome_cc that is the variable that contains wheather the patient is sick or not.


      Code:
      * Example generated by -dataex-. To install: ssc install dataex
      clear
      input long(sex year age_grp) float outcome_cc
      1 2002 15 1
      0 2002 15 1
      1 2002 14 1
      0 2002 17 1
      0 2002 14 1
      0 2002 13 1
      0 2002 13 1
      1 2002 14 1
      1 2002  9 1
      1 2002 15 1
      1 2002 13 1
      0 2002 14 1
      1 2002 10 1
      1 2002 15 1
      1 2002 15 1
      0 2002  9 1
      1 2002 15 1
      1 2002 13 1
      0 2002 13 1
      1 2002 12 0
      end
      label values sex sex_
      label def sex_ 0 "Female", modify
      label def sex_ 1 "Male", modify
      Then i have another ".dta" file with the population strata.

      Wich contains the information of sex, age group and pop (the number of person-year per age-group)

      Code:
      * Example generated by -dataex-. To install: ssc install dataex
      clear
      input long(age_grp pop sex) float year
       1 31994 0 2014
       1 33398 1 2014
       2 32282 0 2014
       2 32782 1 2014
       3 32072 0 2014
       3 32113 1 2014
       4 30687 0 2014
       4 30080 1 2014
       5 27051 0 2014
       5 26484 1 2014
       6 23490 0 2014
       6 22864 1 2014
       7  3467 0 2014
       7  2807 1 2014
       8  3437 0 2014
       8  2750 1 2014
       9  3376 0 2014
       9  2741 1 2014
      10  3588 0 2014
      10  2837 1 2014
      11  3433 0 2014
      11  2802 1 2014
      12  3438 0 2014
      12  2788 1 2014
      13  3406 0 2014
      13  2786 1 2014
      14  3463 0 2014
      14  2753 1 2014
      15  3446 0 2014
      15  2745 1 2014
      16  3408 0 2014
      16  2745 1 2014
      17  3383 0 2014
      17  2722 1 2014
      end
      As I mentioned before the problem is that the command says that it doesnt find the "pop" variable.

      Dont know if i have something wrong in the format of my database or in the code it self.

      Code:
        distrate outcome_cc pop using pop.dta, standstrata(age_grp) popstand(pop) by(year sex) format(%8.1f) mult(100000)

      Can you see any flaws?
      Last edited by dalton norwood; 04 Mar 2019, 09:13.

      Comment


      • #4
        Oh well, you have no pop variable in your first dataset.
        I'm not really sure how the first dataset is set up, but it looks like you have individual-subject data there (I expected to find a "subject ID" variable).
        However, based on #3, maybe something along these lines is what you need (before -distrate-)?

        Code:
        collapse (sum) outcome_cc (count) pop = outcome_cc, by(age_grp sex year)
        (You can omit the popstand(pop)option from the -distrate- command).

        Comment

        Working...
        X