Announcement

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

  • Display long strings in Stata 13

    Hello

    I have several strings variables with more then 100 digits. When using a list command, the stata shrinks it to the window size and never display the full string. What is the best way to deal with it? The project I participate needs constant reports from actions at fieldwork and what I have been doing is exporting every list command to an excel worksheet, but I wanted it to be a normal list displaying the strings in a commom log file smcl.
    What are my options?

    Best,
    George

  • #2
    You may try to use the option - abbreviate(#) - for this.
    Best regards,

    Marcos

    Comment


    • #3
      Loop over observations and display ?

      Comment


      • #4
        Originally posted by Marcos Almeida View Post
        You may try to use the option - abbreviate(#) - for this.
        That won't allow any higher than 33

        Loop over observations and display ?
        How would I do it specific for only observations? Because not everyone has reached that point of interview to show the actions.
        In fact, my list command is :
        list idps dsf2mh1 dsf2mh2 action if dsf2mh1!=.
        I can assume that everyone who answered dsf2mh1 has an string action, but not every observation has reached the point to answer that form in our system (and not necessary will if they get excluded before or any other reason we migth have).

        George

        Comment


        • #5
          I wonder if this excerpt from the Stata Manual may be helpful to you:

          12.4.13 How to see the full contents of a strL or a str# variable
          By default, the list command shows only the first part of long strings, followed by two dots.
          How much list shows is determined by the width of your Results window.
          list will show the first 2,045 bytes of long strings, whether stored as strLs or str#s, if you
          add the notrim option.
          . list, notrim
          (output omitted )
          . list mystr, notrim
          (output omitted )
          . list mystr in 5, notrim
          (output omitted )
          Another way to display long strings is to use the display command. With display, you can see
          the entire contents. To display the fifth observation of the variable mystr, you type
          . display _asis mystr[5]
          (output omitted )
          That one command can produce a lot of output if the string is long, even hundreds of thousands
          of pages! Remember that you can press Break to stop the listing.
          To see the first 5,000 characters of the string, you type
          . display _asis usubstr(mystr[5], 1, 5000)
          For detailed information about displaying Unicode characters beyond plain ASCII characters, see
          [U] 12.4.2.2 Displaying Unicode characters.
          If you want a full listing of a long string, you need to set more off first:
          . set more off
          . display _asis mystr[5]
          (output omitted )
          Very rarely, a string variable might contain SMCL output. SMCL is Stata’s text markup language.
          A variable might contain SMCL if you used fileread() to read a Stata log file into it. In that case,
          you can see the text correctly formatted by typing
          . display as txt mystr[1]
          Note: Nick already pointed out to - display - in #3.
          Best regards,

          Marcos

          Comment


          • #6
            Originally posted by Marcos Almeida View Post
            I wonder if this excerpt from the Stata Manual may be helpful to you:



            Note: Nick already pointed out to - display - in #3.
            Hi. I have tried that, but it unfortunately show it as a kinda of a mess, which might be hard-reading if I have "many" variables listed. For example my output below:

            Click image for larger version

Name:	Sem título.png
Views:	1
Size:	6.5 KB
ID:	1374395

            Comment


            • #7
              Hello George,

              I see the language is Spanish for the string variable.

              In Stata 14, Unicode is supported.

              I guess the issue on your output is due to the fact that you are using Stata 13.

              Hopefully there is some user-written command to cope with that under version 13.
              Best regards,

              Marcos

              Comment


              • #8
                Originally posted by Marcos Almeida View Post
                Hello George,

                I see the language is Spanish for the string variable.

                In Stata 14, Unicode is supported.

                I guess the issue on your output is due to the fact that you are using Stata 13.

                Hopefully there is some user-written command to cope with that under version 13.
                Hi Marcos

                thanks for your input! What I meant by mess is a organization-wise looks. The unicode I can simply work it around by salving my souce csv as ANSI in notepad and it turns out fine. What I meant is that using this is not reading friendly: for example the idps, phq9nivel and the action isn't formatted for easy reading like a normal list command

                George

                Comment


                • #9
                  This is the furthest I can go on this matter. I fear the mainstream use of Stata is, as expected, mostly aimed at dealing with numbers, instead of large chunks of text. Hopefully you will find some user-written program that could perform such a difficult task. Unfortunately, I'm not aware of it, but I gather there might be something. I'm sorry.
                  Best regards,

                  Marcos

                  Comment


                  • #10
                    don't be! But thanks for your input
                    I guess I will have to turn everything with long strings into an excel =P

                    Best,
                    George

                    Comment


                    • #11
                      To display long strings, besides copying to Excel, try the liststr add-on command (under Stata's Help menu, choose Search, and Search net resources).

                      After you install this, you can display full strings in the Stata window, in a form that might be convenient. I do this all the time when I work on patent data with titles and abstracts, often with Unicode characters. It's also useful for tabulations if you need the full strings. It lists in free form, one variable after another, instead of in a grid.

                      Example:
                      Code:
                      . liststr applnTitle applnID app1snam if applnTitleLg!="en":language in 1/300
                      58. METHODE ZUR HERSTELLUNG VON SOLARZELLEN.   14323221 INST MIKROELEKTRONIK IM
                      194. CVD Verfahren zum Herstellen von amorphem Silizium   14042761 AGILENT TECHNOLOGIES INC
                      205. Photovoltaikmodule mit reduziertem Gewicht  323595393 SCHOTT AG
                      225. COMPOSITIONS THERMOPLASTIQUES TRANSPARENTES A HAUTE TENUE THERMOMECANIQUE ET IGNIFUGEES SANS HALOGENE, EN PARTIC
                      > ULIER POUR L'ENCAPSULATION DANS LES MODULES PHOTOVOLTAIQUES  329978079 ARKEMA FRANCE
                      268. 种挤出型太阳能背板及其制备方法  473646028 
                      300. 双轴取向聚酯膜  467732351
                      Example of tabulation:
                      Code:
                      . liststr app1snam if applnAuth=="KR", tab sort
                      LG ELECTRONICS INC 1011
                      LG INNOTEK CO LTD 806
                      SUNPOWER CORP 123
                      FUJIFILM CORP 91
                      SANYO ELECTRIC CO 62
                      CANON KK 53
                      SHARP KK 34
                      MITSUBISHI ELECTRIC CORP 8
                      KYOCERA CORP 3
                      MATSUSHITA ELECTRIC IND CO LTD 2
                      Best,
                      Ken

                      Comment

                      Working...
                      X