Bookmark and Share

Notice: On March 31, it was announced that Statalist is moving from an email list to a forum. The old list will shut down at the end of May, and its replacement, statalist.org is already up and running.


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

Re: st: STATA graph question: Combining Histograms


From   Svend Juul <SJ@soci.au.dk>
To   "statalist@hsphsun2.harvard.edu" <statalist@hsphsun2.harvard.edu>
Subject   Re: st: STATA graph question: Combining Histograms
Date   Thu, 18 Aug 2011 20:07:22 +0200

Marlis wrote:

I am trying to combine frequency histograms for several questions
into one graph.  Each variable has the answers to questions in a
likert scale (always, frequently, infrequently, never, don't know).
I want to plot the frequency and percent for each question side by
side.  Have not found a good way to do this.

**********************************************************

With Likert-type questions, stacked bars communicate efficiently.
Recycling part of Nick's suggestion:

   clear
   set obs 100
   forval i = 1/10 {
         gen answ`i' = ceil(5 * runiform())
   }
   gen id  = _n
   reshape long answ , i(id) j(ques)

   gen x=1
   graph bar (count) x ,           ///
      over(answ) over(ques) asyvars percent stack ///
      bar(1, fcolor(gs0)) ///
      bar(2, fcolor(gs6)) ///
      bar(3, fcolor(gs10)) ///
      bar(4, fcolor(gs13)) ///
      bar(5, fcolor(gs16)) ///
      legend(pos(4) order(5 "strongly disagree" 4 "disagree" ///
         3 "neither-nor" 2 "agree" 1 "strongly agree"))

Hope this helps
Svend
_______________________
Svend Juul
+45 2634 7796
sj@soci.au.dk<mailto:sj@soci.au.dk>


*
*   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–2014 StataCorp LP   |   Terms of use   |   Privacy   |   Contact us   |   Site index