Announcement

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

  • Create several histograms same picture

    Hello,

    I would like to have several histograms in the same picture with the answers (inapplicable, refusal, don´t know, yes, no) to the questions represented by the variables: i_aidhh, cg_scghqa, cg_scghqd, cg_scghqe. The answers would be separed by sex (female. male). I send an example of the dataset below.
    Can you help me with this?
    Thank you in advance.

    ​​​​​​* Example generated by -dataex-. For more info, type help dataex
    clear
    input long(pidp pid) byte i_sex int i_dvage byte(i_aidhh cg_scghqa cg_scghqd cg_scghqe)
    683337457 113050585 2 16 2 2 3 2
    1293998535 -8 1 16 2 4 2 2
    749776179 -8 2 16 2 3 2 2
    272167291 -8 1 16 2 -8 -8 -8
    1031845850 -8 1 16 2 3 2 3
    682492227 -8 1 16 2 1 1 1
    682428973 123427789 1 16 2 2 2 3
    612092499 -8 1 16 2 2 2 3
    701148013 118047434 2 16 2 2 2 3
    1292417539 -8 2 17 2 2 2 1
    546315417 112553435 2 16 2 3 2 3
    1225137655 -8 2 16 2 2 2 2
    1293309015 -8 2 17 2 2 2 1
    1443368130 -8 1 17 2 2 2 2
    1089077815 -8 2 16 2 3 4 3
    1565173695 -8 2 16 2 2 2 3
    1293054011 -8 2 17 2 1 2 3
    1428017015 -8 2 17 2 4 3 4
    1565561979 -8 2 16 2 2 2 2
    274023701 113393075 2 16 2 3 3 2
    632753613 117671118 2 16 2 2 2 2
    1496920063 -8 2 16 2 2 2 2
    1293130179 -8 1 17 2 1 1 1
    1156289695 -8 1 17 2 2 2 1
    1021652415 -8 2 16 2 2 2 2
    748175463 -8 2 16 2 3 4 4
    818669693 124195539 2 16 2 2 2 3
    1497033611 -8 2 17 2 2 2 2
    1158289575 -8 1 16 2 2 2 2
    1578286930 -8 1 16 2 2 2 1
    89129665 107106965 2 16 2 2 2 2
    885066255 -8 1 17 2 2 2 2
    1496734419 -8 1 17 2 4 4 4
    820043297 111214416 2 16 2 2 2 2
    884242099 -8 2 16 2 3 2 3
    1224120379 -8 2 16 2 2 2 2
    816301935 -8 2 16 2 2 2 2
    1428843899 -8 2 17 2 4 2 2
    612794935 -8 2 16 2 2 2 1
    1156923455 -8 2 16 2 3 3 3
    409305619 -8 2 16 2 3 2 2
    818423537 112571875 2 16 2 3 3 2
    1429168935 -8 2 16 2 3 3 3
    953001659 -8 2 16 2 4 3 3
    682408579 -8 1 16 2 2 2 1
    1632393055 -8 2 16 2 3 2 2
    1089013903 -8 2 17 2 3 2 3
    1564188375 -8 2 17 2 3 2 2
    1632393059 -8 2 16 2 1 2 2
    1361071019 -8 1 16 2 3 2 2
    408257737 110343158 2 16 2 2 2 2
    1157109775 -8 1 19 2 1 1 3
    273068975 -8 2 18 2 2 3 3
    436097621 119205149 1 19 1 2 2 2
    1088206059 -8 2 21 2 2 2 2
    1088997575 -8 2 20 2 -8 -8 -8
    1022699623 -8 2 18 2 2 2 2
    204301931 -8 2 17 2 2 2 2
    1033260130 -8 1 19 2 2 3 3
    816538575 -8 1 17 2 2 2 2
    1020498459 -8 2 20 2 3 2 4
    952265211 -8 2 20 2 2 2 2
    682598979 -8 2 20 2 3 2 3
    408102027 -8 2 18 2 4 3 3
    204396455 -8 2 20 2 2 2 3
    205146495 -8 2 18 2 3 3 3
    612576655 -8 1 20 2 2 4 2
    272478059 -8 2 20 2 3 2 2
    476582095 -8 2 19 2 2 2 1
    749782977 93371306 2 18 2 2 2 1
    885302215 -8 1 18 2 2 1 2
    748667779 -8 1 17 2 2 2 1
    204571895 -8 2 20 2 2 2 3
    1498097815 -8 2 21 2 -8 -8 -8
    952273375 -8 2 20 2 2 3 3
    816952699 -8 2 20 2 2 2 3
    817278419 -8 1 18 2 3 3 3
    544668455 -8 2 17 2 2 3 3
    1564084335 -8 2 21 2 2 2 2
    885069655 -8 1 18 2 2 2 2
    544735783 -8 2 18 2 2 2 2
    68197903 -8 1 19 2 2 2 2
    1428017691 -8 1 18 2 2 2 2
    478322891 -8 2 21 2 4 3 3
    768997053 96847891 2 19 2 3 3 3
    70718649 93620659 1 17 2 3 3 4
    612367215 -8 2 21 2 3 3 3
    272023815 -8 2 18 2 2 2 2
    272807175 -8 1 18 2 3 2 3
    1433331334 -8 2 19 2 3 3 4
    1020317575 -8 1 18 2 3 2 3
    1225441615 -8 2 17 2 2 2 3
    892017404 -8 2 17 2 3 2 3
    776221373 119314428 2 19 2 2 2 3
    544280171 -8 1 19 2 2 2 2
    884805815 -8 2 18 2 3 3 3
    409305615 -8 2 17 2 -8 -8 -8
    340329135 -8 2 20 2 3 2 3
    68559659 -8 2 16 2 2 2 4
    544785419 -8 1 20 2 2 3 2
    end
    label values pid pid
    label def pid -8 "inapplicable", modify
    label values i_sex i_sex
    label def i_sex 1 "male", modify
    label def i_sex 2 "female", modify
    label values i_dvage i_dvage
    label values i_aidhh i_aidhh
    label def i_aidhh 1 "Yes", modify
    label def i_aidhh 2 "No", modify
    label values cg_scghqa cg_scghqa
    label def cg_scghqa -8 "inapplicable", modify
    label def cg_scghqa 1 "Better than usual", modify
    label def cg_scghqa 2 "Same as usual", modify
    label def cg_scghqa 3 "Less than usual", modify
    label def cg_scghqa 4 "Much less than usual", modify
    label values cg_scghqd cg_scghqd
    label def cg_scghqd -8 "inapplicable", modify
    label def cg_scghqd 1 "More so than usual", modify
    label def cg_scghqd 2 "Same as usual", modify
    label def cg_scghqd 3 "Less so than usual", modify
    label def cg_scghqd 4 "Much less capable", modify
    label values cg_scghqe cg_scghqe
    label def cg_scghqe -8 "inapplicable", modify
    label def cg_scghqe 1 "Not at all", modify
    label def cg_scghqe 2 "No more than usual", modify
    label def cg_scghqe 3 "Rather more than usual", modify
    label def cg_scghqe 4 "Much more than usual", modify
    [/CODE]
    ---------

  • #2
    this will get you started
    Code:
    twoway hist cg_scghqa if i_sex==1 , color(blue%10) || hist cg_scghqa if i_sex==2 , color(red%10)
    twoway kdensity cg_scghqa if i_sex==1 , color(blue) || kdensity cg_scghqa if i_sex==2 , color(red)

    Comment


    • #3
      Thank you very much!

      Comment

      Working...
      X