Announcement

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

  • Manipulating an already created log-file within Stata

    Hello everyone,

    I would like to manipulate a log file within Stata after it is created. E.g. after creating a log file with various kind of output, I would like to select a specific frequency table within this log file to suppress values that are below a certain value.
    Because log files store all the information as text, I searched for ways to manipulate text within Stata. However, I have found nothing helpful except how to work with string variables. Can someone tell me if it is even possible to manipulate log files as I have described?
    The motivation of my question is to program a (semi-)automated statistical disclosure control with log files as input.

    Best regards
    Benjamin

  • #2
    Yes it’s possible, in the sense that the language is general enough to do what you are asking. However, I doubt that there are any pre-existing user-contributed packages that will do this. My view is that you don’t want to do this. A log file is meant to be a true record of what was done and any resulting output. Instead, statistical outputs like tables should instead be created separately. You can of course automate the creation process, but it ought to be independent of any log records.

    Comment


    • #3
      I quite agree with Leonardo here.

      I'd add that if you could provide a *concrete* illustration of what you have and what you want, that would be very helpful in enabling someone to help you. It sounds like you want to suppress rows of a frequency table from -tabulate-, but I'm not sure.

      Besides that, having a data example that shows your data structure (using -dataex-, per the StataList FAQ for new list members) would be helpful for figuring out what kind of solution might be relevant to your problem.

      Comment


      • #4
        @Leonardo; Mike: Thank you very much for your replies!

        I add a screenshot to illustrate my current “vision” in a better way. On the left is an example of a frequency table stored in a log file. At the moment, I try to find a way to copy paste the frequencies automatically to work with them in Stata like variable values.
        In this example I could then suppress all values of variable RG if a treshold of n ≥ 10 is defined.

        Click image for larger version

Name:	screenshot.jpg
Views:	1
Size:	67.7 KB
ID:	1701457


        Comment


        • #5
          It appears from your table command that you are working in an earlier release of Stata which does not have the latest version of the table command.

          An approach like the following may start you in a useful direction.
          Code:
          . generate N = 1
          
          . collapse (sum) N, by(year grant_type)
          
          . list, clean noobs abbreviate(12)
          
              year   grant_type    N  
              2010            G   15  
              2010            N   59  
              2010            R   71  
              2010          R/G    8  
              2011            G   15  
              2011            N   59  
              2011            R   71  
              2011          R/G    9  
              2012            G   15  
              2012            N   59  
              2012            R   71  
              2012          R/G   10  
          
          . replace N = -1 if N<10
          (2 real changes made)
          
          . table year grant_type, contents(sum N)
          
          ----------------------------------
                    |       grant_type      
               year |    G     N     R   R/G
          ----------+-----------------------
               2010 |   15    59    71    -1
               2011 |   15    59    71    -1
               2012 |   15    59    71    10
          ----------------------------------
          
          .

          Comment

          Working...
          X