Announcement

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

  • Display dollar values in twoway

    In a twoway Stata graph I want to display the x and y tic labels as dollar values. E.g., instead of 50000 I want the graph to show $50,000. What's the most concise way to do that? I know I can say ylabel(0 "$0" 10000 "$10,000" ...) but that gets a bit tedious.

  • #2
    If before twoway I type "format x %9.0fc" and "format y %9.0fc" I get what I want except that there's no leading dollar sign.

    Comment


    • #3
      AFAIK there is no straightforward way to do it. There are previous discussions on the old statalist ( http://www.stata.com/statalist/archi.../msg00900.html ) and they didn't found an answer either.

      Best,
      S

      Comment


      • #4
        Here is an example:

        Code:
        sysuse auto, clear
        scatter price mpg,               ///
            ylabel(    0      "$0.00"    ///
                    5000  "$5,000.00"    ///
                   10000 "$10,000.00"    ///
                   15000 "$15,000.00" )
        I would however prefer the graph below, as I feel that repeating the $ adds no information and distracts from the main message of the graph. It is enough to give the information that the price is in dollars only once in the ytitle:

        Code:
        scatter price mpg,            ///
            ylabel(,format(%9.0gc))   ///
            ytitle("Price (dollars)")
        ---------------------------------
        Maarten L. Buis
        University of Konstanz
        Department of history and sociology
        box 40
        78457 Konstanz
        Germany
        http://www.maartenbuis.nl
        ---------------------------------

        Comment


        • #5
          I am with Maarten on this. Repeating units for each label on an axis is in my view unnecessarily repetitive.

          Nevertheless here is another work-around, using mylabels (SSC) :

          Code:
           
          . ssc inst mylabels 
          . help mylabels 
          
          . mylabels 0(10000)50000, prefix($) myscale(@) local(foo)
          0 "$0" 10000 "$10000" 20000 "$20000" 30000 "$30000" 40000 "$40000" 50000 "$50000"
          Now your labels are in a local macro which you can invoke in a graph command. .

          Interactively that's hardly less typing, but it might help in do-files. The benefits of mylabels lie in more complicated conversions, such as using logit or cube root scales.

          Comment


          • #6

            Thanks for your suggestions! You may be right that the dollar signs are unnecessary, but that decision rightly belongs to the user, not the software. IMO Stata should offer formats for currencies, as SAS does. Then the solution would be simple, something like this: scatter price mpg, /// ylabel(,format(%9.0dollars)) /// ytitle("Price")

            Comment


            • #7
              I take your point, but the decision has so far been made by the software developers, not the software, not to support this.

              I have not seen, or at least do not recall, any discussion by StataCorp personnel, but I imagine that there is a slippery slope argument somewhere, namely if dollars, then also why not Euro, pounds sterling, Yen, etc., etc. and then people start getting disappointed or irritated or offended because their currency is not supported.

              There is a middle road, which could be very interesting at several levels, which is that StataCorp provides scope for users to define their own display formats.

              Again, this is just me speculating. I know nothing about StataCorp intentions here.

              Comment

              Working...
              X