Notice: On April 23, 2014, Statalist moved from an email list to a forum, based at statalist.org.
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: st: Catplot problem
From
Nick Cox <[email protected]>
To
"[email protected]" <[email protected]>
Subject
Re: st: Catplot problem
Date
Tue, 21 Jan 2014 14:17:18 +0000
This works for me
. sysuse auto
(1978 Automobile Data)
. which catplot, all
d:/njc/ado/stbplus\c\catplot.ado
*! 2.0.2 NJC 10 December 2010
. gen himpg = mpg > 20
. catplot himpg foreign, by(rep78)
So, as suggested,
catplot var1 var2, by(var3)
is legal.
Nick
[email protected]
On 21 January 2014 14:00, Neophytos Stylianou
<[email protected]> wrote:
> Thanks Nick for the quick answer
>
> This one works
> catplot category sex agegroup
>
> but not this one
> catplot category sex, by(agegroup)
>
> The result for the second one is as:
> catplot category, by(agegroups)
>
> So it is like it misses the sex variable there
>
> Also in the first one
> catplot category sex agegroups
> it will give the results as in a histrogram from and not separate small graphs on the same plot region
>
> It does in a way solve my problem though so help you very much
>
> Neo
>
> -----Original Message-----
> From: [email protected] [mailto:[email protected]] On Behalf Of Nick Cox
> Sent: 21 January 2014 13:40
> To: [email protected]
> Subject: Re: st: Catplot problem
>
> The limitation here is not that of -catplot- (SSC) but of the -graph- commands it calls, which allow only one variable in a -by()- option.
>
> The help for -catplot- gives examples relevant to your needs.
>
> catplot category sex agegroup
>
> is a legal call, as is
>
> catplot category sex, by(agegroup)
>
> Nick
> [email protected]
>
>
> On 21 January 2014 13:34, Neophytos Stylianou <[email protected]> wrote:
>> Dear Statalist users,
>>
>> I have a problem with plotting a graph.
>>
>> I am using Stata 12.
>>
>> I have a categorical string variable which I want to graph as a bar chart based on each category percentage (below is the tablulation of the variable)
>> CATEGORY Freq. Percent Cum.
>> --------------------------------------------------------------------
>> 01 Accidental: recreation | 25,096 35.72 35.72
>> 02 Accidental: work related | 8,602 12.24 47.96
>> 03 Accidental: not work related | 15,459 22.00 69.97
>> 04 Accidental: unspecified | 14,815 21.09 91.05
>> 05 Assault | 1,244 1.77 92.82
>> 06 Self inflicted | 1,616 2.30 95.12
>> 07 Suicidal | 195 0.28 95.40
>> 08 NAI of child | 213 0.30 95.70
>> 09 Arson | 119 0.17 95.87
>> 98 other | 1,486 2.12 97.99
>> 99 unknown | 1,413 2.01 100.00
>> --------------------------------+-----------------------------------
>> Total | 70,258 100.00
>>
>> Unfortunately Stata won't do it with its graphics options so I used -catplot- which is a user written program downloaded from SSC.
>>
>> I use the following command and it works perfectly
>>
>> catplot category, percent
>>
>> What I want is to have it BY 2 other variables (sex, agegroup)
>>
>> So I am trying to use the command:
>>
>> catplot category, percent by(sex agegroup )
>>
>> But it says too many variables specified r(103).
>>
>> It looks like catplot is able to plot a variable restricted to only one by variable.
>>
>> Is there another way of plotting the graph I want?
>>
*
* For searches and help try:
* http://www.stata.com/help.cgi?search
* http://www.stata.com/support/faqs/resources/statalist-faq/
* http://www.ats.ucla.edu/stat/stata/