Announcement

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

  • Export variable notes

    Hi,

    I am trying to export data in excel, together with variable label information and variable notes information. While it seems rather simple for labels, either indicating this in the export command or creating a variable: gen variable_info = "`: variable label *'" if _n==1, I cannot find a way to do the same for variable notes. I hope I am not just missing a trivial step.
    Thank you for any help!

    Ste

  • #2
    Perhaps the discussion of the additional notes subcommands for programmers found in help notes_ (notice the trailing underscore) will point the way. These were tricky to locate, they are not referenced in the help notes information. I found it through the more general search notes and then looking at the hopeful-seeming matches.

    Comment


    • #3
      Argh, I looked for everything, even _notes, but notes_ ...Exactly what I needed! Thanks a lot!

      Comment


      • #4
        I'm facing a similar situation and would greatly appreciate seeing the code you used to export the variable notes to excel. Would you please post the syntax you got to work?

        Comment


        • #5
          Code:
          * make some notes
          
          sysuse auto, clear
          
          forvalues i=1/3{
              
              foreach v of varlist * {
                  
                  notes `v' : "note `i' to `v'"
              }
          }
          
          * collect notes
          
          collect clear
          
          notes _dir nameswithnotes
          
          foreach name of local nameswithnotes {
              
               notes _count N : `name'
               
               forvalues n = 1/`N' {
                   
                    notes _fetch note : `name' `n' 
                    
                    collect get note = `"note `n' `name': `note'"'
               }
          }
          
          collect layout (cmdset)(result)
          collect export "notes", as(xls) sheet(Sheet1) cell(A1) replace

          Comment

          Working...
          X