Announcement

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

  • tex_equal to compare files/variables

    Hello,

    I have 2 files I want to compare 2 files (each consists of a single string variable - str236 format) which have an unequal number of rows and while the values will mostly overlap I expect some discrepancies. Initially I treated each file as a variable but saw a mention of the add-on tex-equal that can compare files and produce output displaying discrepancies. I tried to find applications of tex-equal and tried 'help tex_equal' without success . I would be interested to hear from anyone who has used the code. Alternatively, in such instances is an option to contact the developer directly?

    I'm happy to post a data example but thought the code may be straight-forward.

    Bob
    Last edited by Bob Green; 21 Apr 2017, 19:58.

  • #2
    What do you mean when you say that you tried help tex_equal without success? Please see section 12 in the FAQ. tex_equal is on SSC and it has a help file that explains how it is used.

    Comment


    • #3
      Checking the output I see that I mistakenly typed help text_equal which produces a message: "help for text_equal not found"

      Typing in the correct spelling for help text_equal the following syntax is listed:

      tex_equal [,
      file1(filename1)
      file2(filename2)
      display
      range(numlist)
      lines(integer)]

      Here is how then tried to run the following code (I tried file names with " " but received the same error:
      tex_equal
      [,
      F:\Original.txt
      F:\New.txt
      display ]


      which produced this error:

      Both files, file1 and file2, should be specified
      invalid syntax
      r(197);


      Any advice is appreciated.

      Bob


      Last edited by Bob Green; 22 Apr 2017, 03:15.

      Comment


      • #4
        You must type

        Code:
        file1(F:\Original.txt) file2(F:\New.txt)
        The option names are not themselves optional.

        Comment


        • #5
          Nick,

          Thanks.

          tex_equal [,
          file1(F:\Original.txt)
          file2(F:\New.txt)
          display ]


          produces:

          . tex_equal [,
          invalid something: unmatched open parenthesis or bracket

          Bob


          Comment


          • #6
            You are expected to omit the square brackets. See

            Code:
            help language
            for more on the difference between syntax diagrams and what you should type.

            It seems a pity that the help for tex_equal doesn't include examples. I have never used it.

            Comment


            • #7
              Nick,

              Thanks. I tried a few options, with & without brackets but the same error

              tex_equal
              file1("F:\Original.txt") file2("F:\New.txt")
              display

              . tex_equal
              Both files, file1 and file2, should be specified
              invalid syntax
              r(197);

              I'll post a new thread and see if what alternative approaches there are.

              Comment


              • #8
                Square brackets are wrong here. They are syntax specification in the same way that noun and verb stand for particular nouns and verbs in discussions of English. .

                Also, please learn about CODE formatting. It takes two minutes. http://www.statalist.org/forums/help#stata

                Code:
                tex_equal, file1("F:\Original.txt") file2("F:\New.txt") display
                may be what you want, but you need all of it. As error messages tell you, the command must know which two files you want to compare. Also, the comma before options is essential.

                Comment


                • #9
                  The problem with the code shown in #7 is that the command given spans three lines, without using continuation characters, so Stata read
                  Code:
                  tex_equal
                  as your entire command, not understanding that you continued it to another line, and told you quite correctly that you had not provided two file names.

                  I'm sympathetic to you as a new user of Stata - it's a lot to absorb. And even worse if perhaps you are under pressure to produce some output quickly. Nevertheless, I'd like to encourage you to take a step back from your immediate tasks. Until you take the time to learn the Stata basics - like how to read the documentation, per #6, and how the commands are to be given, you will persist in making trivially avoidable errors.

                  When I began using Stata in a serious way, I started, as have others here, by reading my way through the Getting Started with Stata manual relevant to my setup. Chapter 18 then gives suggested further reading, much of which is in the Stata User's Guide, and I worked my way through much of that reading as well. There are a lot of examples to copy and paste into Stata's do-file editor to run yourself, and better yet, to experiment with changing the options to see how the results change.

                  All of these manuals are included as PDFs in the Stata installation (since version 11) and are accessible from within Stata - for example, through the PDF Documentation section of Stata's Help menu. The objective in doing the reading was not so much to master Stata as to be sure I'd become familiar with a wide variety of important basic techniques, so that when the time came that I needed them, I might recall their existence, if not the full syntax, and know how to find out more about them in the help files and PDF manuals.

                  The Stata documentation is really exemplary - there's just a lot of it. The path I followed surfaces the things you need to know to get started in a hurry and to work effectively.

                  Comment


                  • #10
                    Thanks William. I'm an occasional user who has learnt the basic tasks that I need to do. Beyond that new tasks remain a steep learning curve, evidenced by a couple of fruitless hours trying to work why I can't merge two files. Michael Mitchell's book and a 3 day training course haven't helped in this regards. Some people can look at an error message and quickly work out what to do, I'm not one of those people. Infrequent use doesn't help.

                    Comment

                    Working...
                    X