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
Logit model - sample size and clustering questionHello, I would like to check if there is a relationship between mothers' fertility and grandparenta…
Problems with articulating survey design for an appended dataset with differing numbers of replicate weightsHello, I am working with the 1996, 2000, 2004 and 2008 state-level waves of the Nursing Workforce S…
MeanHi all, I am running a simulation in STATA and would like to obtain a single mean out of the code b…
Linear mixed models: random effects for both intercept and slope? lincom margins for continuous predictorsHi, I am a student, starting to deal with linear mixed models in STATA and your help would be extre…
Codebook within bys:?I usually use the command -codebook- to undertand the number of unique values of a given variable. I…
Subscribe to:
Post Comments (Atom)
0 Response to Frequency bar graph for multiple binary variables
Post a Comment