Statalist


[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

RE: st: How to plot frequencies of Likert scale over two groups (data shaping question)


From   "Nick Cox" <[email protected]>
To   <[email protected]>
Subject   RE: st: How to plot frequencies of Likert scale over two groups (data shaping question)
Date   Mon, 16 Nov 2009 11:37:47 -0000

If you read in these sample data from Scott's example to have variables
-group- -ease- then 

catplot bar group ease, asyvars 

produces essentially the same graph. -catplot- has been on SSC since
2003 and is discussed in 

SJ-4-2  gr0004  .  Speaking Stata: Graphing categorical and
compositional data
        . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .  N.
J. Cox
        Q2/04   SJ 4(2):190--215                                 (no
commands)
        discusses graphical possibilities for categorical and
        compositional data

In other words, you are not obliged to do your own reshaping or
re-structuring of data. 

Nick 
[email protected] 

Scott Merryman

Do you mean something like this?

clear
input group ease
1 1
1 1
1 2
1 3
1 5
2 1
2 2
2 3
2 4
2 5
end
egen freq = count(ease), by(gr eas)
replace freq = freq/_N
duplicates drop
reshape wide freq, j(gr) i(ea)
graph bar (asis) freq1 freq2, over(ease)

On Thu, Nov 12, 2009 at 8:17 AM, Philip Jones <[email protected]> wrote:

> After substantial frustration at my inability to simply perform this
task in Stata, I am asking this group for help!
>
> I know that it will be easy to answer, but I am unable to come up with
the correct way of shaping my data for the following need of graphing.
>
> I have a Likert scale (1 to 5) that two groups of people answered. I
would like to create a bar graph with the x axis labelled 1, 2, 3, 4, 5
for each Likert level. I would then simply like to plot frequencies of
responses as the bars, so that each level of the Likert scale would have
one for each group (i.e. two bars of frequencies for each of 1, 2, 3, 4,
5).
>
> My attempt (which creates the look of the graph that I want):
>
> clear *
> input ease_level group1 group2
> 1 24 26
> 2 13 15
> 3 12 12
> 4 8 6
> 5 1 6
> end
>
> graph bar (asis) group1 group2, over(ease)
>
> This works well, except my data are not in this format. Rather, they
are in the following format:
>
> clear *
> input group ease
> 1 1
> 1 1
> 1 2
> 1 3
> 1 5
> 2 1
> 2 2
> 2 3
> 2 4
> 2 5
> end
>
> I have searched the re-shaping commands, but cannot successfully
convert my data to this format.
>

*
*   For searches and help try:
*   http://www.stata.com/help.cgi?search
*   http://www.stata.com/support/statalist/faq
*   http://www.ats.ucla.edu/stat/stata/



© Copyright 1996–2024 StataCorp LLC   |   Terms of use   |   Privacy   |   Contact us   |   What's new   |   Site index