Announcement

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

  • How to combine the number of cases based on code group and age group into common group?

    Dear All,

    I am new to stata and hoping I can get possible tips or solutions to my queries. I have variable health codes and age groups in which a number of patient cases are already categorized. Health codes are around 5000 obs and have a common group, let`s say codes 0-15 belong to common group A, health codes 16-25 belong to common group B and all these codes have a number of patient cases which should be summed up. I tried to use frequency analysis using the command "table" to combine every health code and age group into a common group showing the total of patient cases but I didn`t get a table I needed. kindly see below the command I tried to use and the sample raw data I am working on:

    table (year country age group) (common group patientcases), statistic(rawtotal patientcases)

    year country health codes age group common group patient cases

    2015 US……01………………0-14………….A……………….5
    2015 US……05………………40-69……….A………………..30
    2015 US……10………………15-39………..A……………….15
    2015…US……06………………40-69……….A…………………100
    2015...UK……02……………….70+………….A……………….80
    2015…UK……07………………0-14…………A………………25
    2015…UK……08………………40-69………..A………………..200
    2015…UK……11……………...70+…………..A………………..150
    2016…US……13……………..15-39…………A………………30
    2016…US……14…………….0-14…………..A……………….20
    2016…US…….20…………….15-39…………B………………32
    2016…US……25…………….39-40………….B………………..70
    2016…UK……18……………40-69………….B………………..90
    2016…UK……15…………....70+…………….A………………..10
    2016…UK……16……………0-14……………B………………..30
    2016…UK…….08………….15-39……………A……………….30
    2017…US……13…………..0-14…………….A……………….20
    2017…US……19………….15-39……………B……………….10
    2017…US…….23…………..40-69………….B………………35
    2017….US……22………….70+……………..B………………15
    2017…UK…….24………….0-14…………….B……………….60
    2017….UK……11…………15-39……………A………………15
    2017…UK……25………….40-69……………B………………10
    2017…UK…….21…………70+………………B……………….50


    What am I missing here? Did I use the wrong command? or is there just something to correct in the data arrangement? I appreciate any help you may provide.


    Kind Regards,
    Rosie

  • #2
    Rosie:
    welcome to this forum.
    You may want to take a look at the -total- function available from -egen-.
    For the future, please share what you typed and what Stata gave you back via CODE delimiters and/or provide an excerpt/example of your dataset via -dataex- (see the FAQ for further details). Thanks.
    Kind regards,
    Carlo
    (Stata 19.0)

    Comment

    Working...
    X