Announcement

Collapse
No announcement yet.
X
  • Filter
  • Time
  • Show
Clear All
new posts

  • Graph with only one stacked variable and error code 198

    Hello everyone,

    I have two very simple questions:

    1. I am trying to make a bar graph with two variables. The variables are meanEI and EER. It sounds simple, however, EER is a sum of two other variables: TEE and Eg.

    I want to plot meanEI and stacked TEE and Eg.

    I used the following code but it does not include anything relating to stack (see Graph.png). I want only Estimated TEE and Estimated Eg to be on top of each other.

    Code:
    graph bar (mean) meanEI (mean) TEE Eg, over(description2) ytitle(Energy (kcal)) ///
        title(Figure: Mean EI and estimated energy expenditure (TEE+Eg) by age, size(med) ///
        justification(center)) legend(on) scheme(s2mono) graphregion(color(white)) ///
        legend(order( 1 "Mean reported EI" 2 "Estimated TEE" 3 "Estimated Eg")) legend(size(med)) ///
        note(*EI = Energy Intake; TEE = total energy expenditure; Eg = energy needs for deposition) ///
        b1title(Age (months))
    2. I am trying to make a second graph of a variable with three categories. The following code is for count (to give you an idea of what I want) . See Graph2.png

    Code:
    graph bar (count)  n, over( report_BC1_1sd) stack over(des) ascategory asyvars scheme(s1mono)
    When I tried using percentage instead of count, Stata gives me an error saying:

    (ercent) invalid statistic
    r(198);

    I am wondering why Stata says "ercent" and not "percent". I used the following code:
    Code:
    graph bar (percent)  n, over( report_BC1_1sd) stack over(des) ascategory asyvars scheme(s1mono )
    Any help would be appreciated!
    Attached Files

  • #2
    #1 Your example is not reproducible, but I see no stack option. stack is certainly necessary for stacking, although it may not be sufficient.

    #2 (percent) was introduced during Stata 13. Perhaps you need to update your Stata.

    Comment

    Working...
    X