Announcement

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

  • #16
    Dear Nick,
    you got the problem, I had not the last version of tabplot.

    Thanks a lot for your and Andrew's kindness.

    Have a nice evening, G

    Comment


    • #17
      By the way, is that possible to show always two digits (for instance, not 4 but 4,0 and not ,2 but 0,2)?

      I tried with -format num %9,0gc- but Stata runs into the error 'invalid syntax'
      Thanks, G

      Comment


      • #18
        What's num ? It is not in your data example.

        This works and is documented:

        Code:
        gen percshow = string(perc, "%9,0gc")
        
        tabplot setto anno [iw=perc], by(uomo, compact note("") title("Distribuzione di genere nelle professioni", place(e))) ///
        subtitle(, fcolor(none)) showval(percshow, mlabsize(vsmall)) ///
        xtitle("") ytitle("") yla(, labsize(medsmall)) ///
        separate(uomo) bar1(bfcolor(red*0.2) blcolor(red)) bar2(bfcolor(blue*0.2) blcolor(blue))

        Comment


        • #19
          Dear Nick, thanks again for your help.

          I tried the command, it seems to work but still no 0 in the graph.

          Could it be something related to an old version of a given command? I would say no, because you added only a simple -gen- and the variable -percshow- after showval, right?

          I also tried with - format perc %9,0gc- but nothing change.

          thanks, g

          Comment


          • #20
            Try %09,0gc

            Comment


            • #21
              You mean -gen percshow = string(perc, "%09,0gc")- instead of -gen percshow = string(perc, "%9,0gc")-, right?

              Always the same...

              Comment


              • #22
                Maybe is related to the fact that I sun -set dp comma- at the beginning?

                If I try with -"%03.2f"- I obtain number such as "0.50" with point instead of comma (when I would have "0,5" in this example)

                Comment


                • #23
                  You're right. Stata ignores a leading zero in %09,2gc. But what you want is just more string manipulation:


                  Code:
                  gen percshow = string(perc, "%9,0gc") 
                  replace percshow = "0" + percshow if substr(percshow, 1, 1) == "," 
                  tabplot setto anno [iw=perc], by(uomo, compact note("") title("Distribuzione di genere nelle professioni", place(e))) ///
                  subtitle(, fcolor(none)) showval(percshow, mlabsize(vsmall)) ///
                  xtitle("") ytitle("") yla(, labsize(medsmall)) /// 
                  separate(uomo) bar1(bfcolor(red*0.2) blcolor(red)) bar2(bfcolor(blue*0.2) blcolor(blue))

                  Comment


                  • #24
                    Dear Nick, thanks a lot, I was not aware of the option 'substr'.

                    Now it works and I have 0,5 instead of ,5.

                    But how if I would like to have 7,0 instead of 7? Is something still related to the specification of 'substr'?

                    thanks g

                    Comment


                    • #25
                      You don't need the substr() function (not option) at all. This ticks all boxes, as I should have seen earlier.

                      Code:
                      gen percshow = string(perc, "%04,1fc") 
                      tabplot setto anno [iw=perc], by(uomo, compact note("") title("Distribuzione di genere nelle professioni", place(e))) ///
                      subtitle(, fcolor(none)) showval(percshow, mlabsize(vsmall)) ///
                      xtitle("") ytitle("") yla(, labsize(medsmall)) /// 
                      separate(uomo) bar1(bfcolor(red*0.2) blcolor(red)) bar2(bfcolor(blue*0.2) blcolor(blue))

                      Comment

                      Working...
                      X