There are several questions here. Your bottom line as I understand it
is that you want -graph bar- to show you counts or frequencies.
That isn't what -graph bar (asis)- does at all. It shows the raw data.
"asis" means "as is".
It doesn't count for you.
If you want bars of counts, then -contract- the data first. Alternatively,
look at -catplot- on SSC.
For example, if I read in
. sysuse auto, clear
And ask for
. graph bar (asis) foreign, over(rep78)
variables rep78 _variables do not uniquely identify the observations
r(459);
I get the same kind of message. What you may want instead is something more like
. catplot bar foreign rep78
Or
. catplot bar rep78 foreign
See also
<http://www.stata-journal.com/sjpdf.html?articlenum=gr0004>
for more discussion.
The various error messages you get are not especially comprehensible.
Although it is not very helpful to say so, the best way to consider them
is as indicating that Stata is having difficulty making sense of your instruction.
As you appear to be expecting something that -graph bar- doesn't promise to
do, that is likely to be the root of the problem.
Nick
[email protected]
Tunga Kantarci
I use the following command to generate a categorized bar graph:
graph bar (asis) q41a if grandom == 1, over(frandom_)
However, I receive the following message:
variables frandom_ _variables do not uniquely identify the observations
I don't understand why my "frandom_" variable need to identify the
observations uniquely.
(by the way I have an "id" variable which uniquely identifies observations)
I also do not understand what "_variables" refers to.
If I run the command without "asis" then I get the following:
graph bar q41a if grandom == 1, over(frandom_) variable __000006 not found
in using data
In particular, what I am trying to do is this: see the three tabulations
below. What I want is a categorized bar graph, where the categorization is
over frandom. That is, three bars in a bunch will present together "Plan van
name5", where each bar refers to one of the "frandom"s. There will be three
bunches with each bunch having three bars. But unfortunately, I receive the
message I mentioned.
�
tab q41a if grandom == 1 & frandom == 1
q4 age |
randomisation 1 3/4 | Freq. Percent Cum.
--------------------+-----------------------------------
plan van ^name5 | 21 42.00 42.00
plan van ^name6 | 14 28.00 70.00
plan van ^name7 | 15 30.00 100.00
--------------------+-----------------------------------
Total | 50 100.00
�
tab q41a if grandom == 1 & frandom == 2
q4 age |
randomisation 1 3/4 | Freq. Percent Cum.
--------------------+-----------------------------------
plan van ^name5 | 32 61.54 61.54
plan van ^name6 | 10 19.23 80.77
plan van ^name7 | 10 19.23 100.00
--------------------+-----------------------------------
Total | 52 100.00
�
tab q41a if grandom == 1 & frandom == 3
q4 age |
randomisation 1 3/4 | Freq. Percent Cum.
--------------------+-----------------------------------
plan van ^name5 | 23 58.97 58.97
plan van ^name6 | 4 10.26 69.23
plan van ^name7 | 12 30.77 100.00
--------------------+-----------------------------------
Total | 39 100.00
tab frandom
q4 |
(standard) |
item |
randomizati |
on | Freq. Percent Cum.
------------+-----------------------------------
1 | 627 34.19 34.19
2 | 600 32.72 66.90
3 | 607 33.10 100.00
------------+-----------------------------------
Total | 1,834 100.00
tab grandom
q4 |
(standard) |
item |
randomizati |
on pension |
income | Freq. Percent Cum.
------------+-----------------------------------
1 | 465 25.35 25.35
2 | 478 26.06 51.42
3 | 452 24.65 76.06
4 | 439 23.94 100.00
------------+-----------------------------------
Total | 1,834 100.00
tab q41a
q4 age |
randomisation 1 3/4 | Freq. Percent Cum.
--------------------+-----------------------------------
Plan from ^name5 | 220 52.26 52.26
Plan from ^name6 | 53 12.59 64.85
Plan from ^name7 | 148 35.15 100.00
--------------------+-----------------------------------
Total | 421 100.00
*
* For searches and help try:
* http://www.stata.com/support/faqs/res/findit.html
* http://www.stata.com/support/statalist/faq
* http://www.ats.ucla.edu/stat/stata/