Hello,

I have an example of the dataset below (survey). I would like to do a histogram with the answers (inapplicable, refusal, don´t know, yes, no) of the variable "i_aidhh" by sex (variable i_sex). Can you help me with this?
Thank you in advance.


----------------------- copy starting from the next line -----------------------
Code:
* Example generated by -dataex-. To install: ssc install dataex
clear
input long(pidp pid) byte i_sex int i_dvage byte i_aidhh
   76165  10689869 2 34  2
  732365  15752658 1 32  1
 1587125  17870879 2 51  1
 4849085 176725733 1 34  2
68002725  10023526 2 63 -8
68008847        -8 2 59 -8
68010887        -8 2 53  2
68029931        -8 1 48  2
68031967        -8 2 69 -8
68035365  10403086 1 65 -8
68035367        -8 1 36  2
68041487        -8 2 47  2
68041491        -8 1 44  2
68045567        -8 2 55  2
68051007        -8 1 56  2
68051011        -8 2 49  2
68058487        -8 1 77  2
68058491        -8 2 68  2
68060531        -8 2 44  2
68060533 160066204 2 61  1
68060537 160066239 1 73  2
68063247        -8 2 50  2
68063927        -8 2 47  2
68063931        -8 1 49  2
68064605  10653872 1 68  2
68064609  10653902 2 65  2
68068007        -8 1 50  2
68068082        -8 1 56  2
68097245  10913629 2 67 -8
68097927        -8 2 68 -8
68120367        -8 2 66 -8
68120375        -8 2 37 -8
68125127        -8 2 51  2
68125131        -8 1 26  2
68125135        -8 2 21  2
68133285  11218193 2 68 -8
68133289  11218282 2 32  2
68136009  11234989 2 65  2
68137365  11240547 2 63 -8
68138045  11242787 1 68  2
68138049  11242817 2 67  1
68138051        -8 2 63  2
68144847        -8 1 49  2
68144851        -8 2 41  2
68148247        -8 1 69  2
68150971        -8 2 58  2
68150975        -8 1 29  2
68155047        -8 2 60  2
68155051        -8 1 65  2
68157771        -8 2 23  2
68159131        -8 2 37  1
68160485  11418567 2 66  2
68160489  11418591 1 41 -8
68173407        -8 2 60  2
68180887        -8 2 47  2
68184971        -8 2 42  2
68185647        -8 2 55  2
68187687        -8 1 62  2
68187691        -8 2 58  2
68191771        -8 2 45  2
68193127        -8 2 64  2
68195167        -8 1 74  2
68195171        -8 2 74  2
68195851        -8 2 43  2
68197887        -8 2 56  2
68197899        -8 2 22  2
68197903        -8 1 19  2
68199247        -8 1 33  2
68207407        -8 2 72  2
68207411        -8 1 78  2
68211487        -8 1 65 -8
68214207        -8 1 58 -8
68216247        -8 2 43  2
68218287        -8 1 74  2
68231223        -8 2 18  2
68238011        -8 2 59  2
68262487        -8 1 47  2
68266567        -8 2 80 -8
68278127        -8 2 70 -8
68288327        -8 2 44  2
68288331        -8 1 44  2
68291731        -8 2 62 -8
68293087        -8 2 49  2
68293091        -8 1 54  2
68293095        -8 1 29  2
68293099        -8 1 26  2
68293168        -8 1 28  2
68294447        -8 1 60  2
68294451        -8 2 44  2
68297845  12521361 1 63  2
68297849  12521396 2 61  2
68297857  12521469 2 30  2
68299207        -8 2 60  2
68302611        -8 2 74  2
68309407        -8 2 62  2
68321647        -8 1 60  2
68321651        -8 2 60  2
68322327        -8 2 50  2
68322331        -8 1 57  2
68329807        -8 2 51  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 -8 "inapplicable", modify
label def i_aidhh 1 "Yes", modify
label def i_aidhh 2 "No", modify
Best regards