I have a string variable (Reasons_Inadmissible) with multiple values that are comma separated. It lists all of the reasons why a case is inadmissible; multiple reasons can be listed in one cell. For example, one cell will read HRM, another will read HRM, LAW, another will read LAW, etc. Other values include REP, LON, OTE and others. I am trying to produce a frequency bar graph which indicates the number of cases where Reasons_Inadmissible is HRM, the number of cases where Reasons_Inadmissible is LAW, etc. In other words, I want a bar chart to indicate the number of cases that invoked a particular reason. Individual cases can be double-counted in this bar chart. I tried:
catplot Reasons_Inadmissible
But, it produces a bar chart with all possible combinations (i.e. HRM; HRM, LAW; HRM, OTE; LAW; OTE). Instead, I want the bars to represent the number of cases where one of the reasons was listed (just HRM, LAW, REP, OTE-- individually).
One options would be to generate a series of binary variables that are equal to 1 for each Reasons_Inadmissible value. For example:
gen HRC = 1 if strpos(Reasons_Inadmissible,"HRC")
gen LAW = 1 if strpos(Reasons_Inadmissible,"LAW")
However, in that case, how do I generate a bar graph, where the bars are counts of the different binary variables? Alternatively, is there another way you would recommend generating this graph from a comma-separated categorical variable?
Thanks!
Erica
Related Posts with Frequency bar graph for multiple binary variables
Difference in the estimate between subsample and interaction modelHi all This question might be stupid but I am really curious. Suppose I want to run the following …
Unconditional cross-nested 4-level modelDear all, I would like to replicate a paper (https://onlinelibrary.wiley.com/doi/10.1002/smj.3057) …
Creating huge number of fixed effectsHi everyone, I have a large firm level panel with 1 million units over 20 years. I want to run a di…
how to calculate the cumulative mean by groups?For example, for the observation group 1 time 1, the cumulative mean is missing; for observation gro…
ARDL modelHow to estimate a ARDL model with interaction variables ? First, i used the PCA method to generate t…
Subscribe to:
Post Comments (Atom)
0 Response to Frequency bar graph for multiple binary variables
Post a Comment