Announcement

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

  • Aweights in graph not working

    Dear Experts,

    I have a following simple code, which intends to produce a scatterplot of items which have sales and that do not.
    I also want to show the size of sales in the graph with the help of [aw = total_SalesRevenue_EUR_per_Year].

    But somehow the code does not work and i receive an empty graph window.

    If i use scatter MM_Volume TP if total_SalesRevenue_EUR_per_Year == 0, mcolor(navy) msymbol(circle)) alone, no problems appear and i get the results.

    I should mention that for this graph total_SalesRevenue_EUR_per_Year are 0, but i still need this kind of code, as it runs for different groups, some of which also have sales present.

    Code:
    twoway ///
    (scatter MM_Volume TP [aw = total_SalesRevenue_EUR_per_Year], ytitle(Material Margin (%)) xtitle(TP (€)) mcolor(navy) msymbol(circle_hollow)) ///
    (scatter MM_Volume TP if total_SalesRevenue_EUR_per_Year == 0, mcolor(navy) msymbol(circle))
    How should i get it work having [aw = total_SalesRevenue_EUR_per_Year] inside even if total_SalesRevenue_EUR_per_Year = 0?

    hope i described an issue well enough.

    Sincerely,

    Pavlo

  • #2
    Issue solved. I have created a local macro which solves it and substituted into graph code

    Code:
    su total_SalesRevenue_EUR_per_Year if min_Sequence_num == `n'
                    local s = r(mean)
                    
                    local aw = cond(`s' != 0, "[aw = total_SalesRevenue_EUR_per_Year]", "")
    Code:
     
     twoway /// (scatter MM_Volume TP `aw', ytitle(Material Margin (%)) xtitle(TP (€)) mcolor(navy) msymbol(circle_hollow)) /// (scatter MM_Volume TP if total_SalesRevenue_EUR_per_Year == 0, mcolor(navy) msymbol(circle))

    Comment

    Working...
    X