Announcement

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

  • Quotes in tsline axis labels

    Does anyone know why the second version, where the two-digit year is preceded by the single quote, fails?

    Code:
    clear
    input t y
    7213  0 
    20567 36
    end
    format t %td
    list y t
    tsset t
    
    di %tddd_Mon,_YY 20567
    di %tddd_Mon,_'YY 20567
    
    tsline y, tlabel(#2, format(%tddd_Mon,_YY))
    tsline y, tlabel(#2, format(%tddd_Mon,_'YY))

  • #2
    I've played around with this for a while, but could not get tsline to give the desired format. Note the apostrophe is not among the list of characters allowed in formats (help datetime display formats). However, as Dimitriy shows, Stata allows it in di %tddd_Mon,_'YY 20567 (you would expect that the apostrophe would only be allowed if preceded by an exclamation point, as in di %tddd_Mon,_!'YY 20567), but tsline allows neither ' nor !'.

    I tried various approaches including:

    Code:
    tsline y, tlabel(#2, format(%tddd_Mon,_`=char(39)'YY))       // `=char(44)' works
    As well as specifying the apostophe within adorned macros and unexpanded macros--all to no avail.

    Perhaps someone else will have better luck!

    Stata/MP 14.1 (64-bit x86-64)
    Revision 19 May 2016
    Win 8.1

    Comment


    • #3
      Perhaps escaping the character would work?

      Comment


      • #4
        I tried the escaping backslash earlier, but it seems to fail as well.

        I guess we will have to file this with the song the Sirens sang and the name Achilles used when he hid among the women.
        Last edited by Dimitriy V. Masterov; 24 Apr 2016, 14:28.

        Comment


        • #5
          Dimitriy V. Masterov I've had similar issues with variable labels that contain apostrophes causing problems. My best guess is that is has something to do with the ` and ' characters being used to denote local macros. Are there any cases where you have overlapping decade/year values (e.g., the graph would show something from 1900-1916 as well as 2000-2016)? If not, I can't imagine using the two digit years without an apostrophe would cause too much harm (unless of course it is just some random/arbitrary formatting rule that is being imposed on you). The other option might be to try embedding the date string as a value label and using one of the normal line graph functions.

          Comment


          • #6
            wbuchanan Fortunately I am in tech, so we don't have data that predates the commercial internet. This attempt to economize on digits is mostly for educational purposes. I tried to do something and was surprised and puzzled by the result.

            Comment

            Working...
            X