Announcement

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

  • Accessing information in -notes- with a program, or alternative?

    I'd like for a program to be able to access the information in the -notes- attached to a data file. As nearly as I can tell, there is no documentation in -notes- for how to do this, so perhaps someone has an alternative idea of how to accomplish the same end.

    Here's the context: I'm generating a large number of simulated data files, each with _N =10,000, and I was planning to put into the -notes- of each simulated data file several pieces of descriptive information about that file (distributions of variables, etc.). Then, while using each data file for a series of bootstrap experiments, I would like to be able to extract the information from the -notes- as I use each file. Since I don't see any way to put a note into (say) a -local-, the only alternative I can think of is to create a string variable in each simulated data file, rather than a -note-, that contains the information. I guess that would work, but the string variable would use length(string) *10000*_N bytes, which is rather clumsy and a waste. Another way I've approached a problem like this is to put the -notes- information into the file name of each simulated data file, but that seems clumsy as well. Any other suggestions here?

    Regards, Mike

  • #2
    Notes are implemented using dataset characteristics, see help char.

    Here's a quick example of how to access notes

    Code:
    clear
    sysuse auto
    notes: One more dataset note
    notes make: This is a string var
    notes make: Another note
    char list
    
    forvalues i=1/`_dta[note0]' {
        dis "`_dta[note`i']'"
    }
    
    forvalues i=1/`make[note0]' {
        dis "`make[note`i']'"
    }

    Comment


    • #3
      IIRC, notes are a form of characteristic and those can be dealt with, I think, in the way you want; see [P]char

      Comment


      • #4
        Technically notes are characteristics, so they can be accessed via extended functions. Here is an example

        Code:
        sysuse auto
        
        loc note1 : char _dta[note1]
        di "`note1'"
        Best
        Daniel

        Comment


        • #5
          Thanks to all. Just what I needed to know but couldn't seem to find. - Mike

          Comment


          • #6
            I think it's perfectly fine to use characteristics to access notes, but there are also programmer's commands to manage them: see help notes_. For instance, you can retrieve the contents of a note using notes _fetch.

            Comment


            • #7
              This is the kind of thing I was searching for. I'm puzzled, though, as to why -help notes- has no "see also" or similar link to -help notes_. I see now that -search program notes- would have led me there.

              Thanks, Mike

              Comment


              • #8
                In Stata 13.1, the help for notes has an Also see that points to notes_

                Comment

                Working...
                X