Announcement

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

  • Symbols in variable and value labels

    I want to label values with >= sign and <= symbols. I know the use in twoway options with the &gt etc, but don't know how to use for a value label in a variable or variable label for that matter. I end up having to change things manually in MS Word after exporting a table etc. which I don't want to. Seems like a simple thing but I cannot find the help area to look for in the manual for this.

  • #2
    I don't know what the question is here as you are saying you know how to use what you need....

    In my experience using SMCL markup for special characters is invaluable for special characters and so forth in graphs, but not otherwise.

    Code:
    help text 
    gives the list of possibilities. Your usage may vary a lot but my list of often used symbols includes

    inequality symbols (as said)

    minus signs (which are not hyphens or dashes)

    Greek characters

    degree symbols

    italic when customary in mathematics

    Comment


    • #3
      Originally posted by Nick Cox View Post
      I don't know what the question is here as you are saying you know how to use what you need....

      In my experience using SMCL markup for special characters is invaluable for special characters and so forth in graphs, but not otherwise.

      Code:
      help text 
      gives the list of possibilities. Your usage may vary a lot but my list of often used symbols includes

      inequality symbols (as said)

      minus signs (which are not hyphens or dashes)

      Greek characters

      degree symbols

      italic when customary in mathematics
      To clarify, my use case is related to only variable labels and value labels. For instance, I want to have the variable label as "Albumin >=3.5 g/dL" (with Yes and No for the binary choices for value labels). I am unable to use smcl for the -greater or equal to- symbol as I would in graph text. I have several such variables with needs for italics and superscripts that I would like to label once and for all while defining variables so I would not have to reconfigure my descriptive table text in MS Word after exporting.

      Comment


      • #4
        Originally posted by Girish Venkataraman View Post
        I am unable to use smcl for the -greater or equal to- symbol as I would in graph text.

        I have several such variables with needs for italics and superscripts that I would like to label once and for all while defining variables so I would not have to reconfigure my descriptive table text in MS Word after exporting.
        On the first point, Nick has said in #2 that you can't use SMCL characters or directives outside of graphs. If you want the greater-than-or-equal to character, that just put in that character with an appropriate character. Likewise for all other Unicode characters. Here's a way to insert such a character with Stata code.

        Code:
        clear
        input albumin
        0
        1
        end
        
        local ge = ustrunescape("\u2265")
        
        label define albumin 0 "No, < 3.5 g/dL", modify
        label define albumin 1 "Yes, `ge' 3.5 g/dL", modify
        label values albumin albumin
        label var albumin "Albumin, `ge' 3.5 g/dL"
        codebook albumin
        Relevant output

        Code:
        . codebook albumin
        
        -------------------------------------------------------------------------------
        albumin                                                     Albumin, ≥ 3.5 g/dL
        -------------------------------------------------------------------------------
        
                          Type: Numeric (double)
                         Label: albumin
        
                         Range: [0,1]                         Units: 1
                 Unique values: 2                         Missing .: 0/2
        
                    Tabulation: Freq.   Numeric  Label
                                    1         0  No, < 3.5 g/dL
                                    1         1  Yes, ≥ 3.5 g/dL
        On the second point, again you can't have text formatting like italics or bolding in value or variable labels. (As an aside, I'm not aware of *any* statistical program that allows this.) Frankly, I don't think it's really a useful addition because the raw text of the labels should convey all necessary information for that variable, and if more information is needed, then the documentation can supply further details.

        Comment


        • #5
          Originally posted by Leonardo Guizzetti View Post

          On the first point, Nick has said in #2 that you can't use SMCL characters or directives outside of graphs. If you want the greater-than-or-equal to character, that just put in that character with an appropriate character. Likewise for all other Unicode characters. Here's a way to insert such a character with Stata code.

          Code:
          clear
          input albumin
          0
          1
          end
          
          local ge = ustrunescape("\u2265")
          
          label define albumin 0 "No, < 3.5 g/dL", modify
          label define albumin 1 "Yes, `ge' 3.5 g/dL", modify
          label values albumin albumin
          label var albumin "Albumin, `ge' 3.5 g/dL"
          codebook albumin
          Relevant output

          Code:
          . codebook albumin
          
          -------------------------------------------------------------------------------
          albumin Albumin, ≥ 3.5 g/dL
          -------------------------------------------------------------------------------
          
          Type: Numeric (double)
          Label: albumin
          
          Range: [0,1] Units: 1
          Unique values: 2 Missing .: 0/2
          
          Tabulation: Freq. Numeric Label
          1 0 No, < 3.5 g/dL
          1 1 Yes, ≥ 3.5 g/dL
          On the second point, again you can't have text formatting like italics or bolding in value or variable labels. (As an aside, I'm not aware of *any* statistical program that allows this.) Frankly, I don't think it's really a useful addition because the raw text of the labels should convey all necessary information for that variable, and if more information is needed, then the documentation can supply further details.
          Thanks much for pointing out a method to do it. I will try to see how I can work this into my workflow for tables with variables and labels. I seem to need it for things like microliter and gene names that are italicized in table depictions. I will try to do a few variables with your method and see how it works for me. Defining as locals is going to impact is going to force me to redefine every time I use the variable outside the scope of the local. Perhaps I will have a separate relabel file with global macros for special variables like these.

          Comment


          • #6
            Defining as locals is going to impact is going to force me to redefine every time I use the variable outside the scope of the local. Perhaps I will have a separate relabel file with global macros for special variables like these.
            I suggest you make a do file that defines all of the locals you need for the special characters you use frequently. You can then -include- that file in any do file or program where you need its contents. -include- is one of Stata's least known but most useful commands. Do read -help include- for details.

            Comment


            • #7
              Great idea. I had just started generously including several -include- files into my workflow hoping to submit all analysis related code as a supplement to the manuscript (the only limiting factor seems to be my organization skills with keeping the paths straight). This character/symbol -include- file will be a great idea to work on.

              Comment

              Working...
              X