Mass producing appendices using stata and word processor mail merge l.jpg
This presentation is the property of its rightful owner.
Sponsored Links
1 / 11

Mass producing appendices using Stata and word processor mail merge PowerPoint PPT Presentation


  • 210 Views
  • Uploaded on
  • Presentation posted in: General

Mass producing appendices using Stata and word processor mail merge. NASUG July 11, 2005 by: Michael Blasnik M. Blasnik & Associates, Boston, MA. Background. Needed to produce appendix containing some data, analysis results, and graphs for each of 186 “panels” in a panel dataset

Download Presentation

Mass producing appendices using Stata and word processor mail merge

An Image/Link below is provided (as is) to download presentation

Download Policy: Content on the Website is provided to you AS IS for your information and personal use and may not be sold / licensed / shared on other websites without getting consent from its author.While downloading, if for some reason you are not able to download a presentation, the publisher may have deleted the file from their server.


- - - - - - - - - - - - - - - - - - - - - - - - - - E N D - - - - - - - - - - - - - - - - - - - - - - - - - -

Presentation Transcript


Mass producing appendices using stata and word processor mail merge l.jpg

Mass producing appendices using Stata and word processor mail merge

NASUG July 11, 2005

by: Michael Blasnik

M. Blasnik & Associates, Boston, MA


Background l.jpg

Background

  • Needed to produce appendix containing some data, analysis results, and graphs for each of 186 “panels” in a panel dataset

    • Panels= refrigerators: project involved assessing energy performance of refrigerators in 186 homes in New England on behalf of three utilities

    • Produce one page summary for each unit that includes 3 graphs -- total of 186 pages and 558 graphs

    • Wanted to be able to easily update and revise – no one-by-one inserting/pasting of data or graphs


Overall approach l.jpg

Overall Approach

  • Use “mail merge” facility of word processor, like a 1 page form letter

    • Use Stata to automatically create all of the graphs (exported to usable format such as .emf in Windows) and write needed data out to tab-delimited text file using outsheet

    • Use Word Processor Mail Merge to lay out page, insert references to data fields in .txt file, and include references to the names of the graphs created in graph fields


Specific approach stata l.jpg

Specific Approach: Stata

  • Use do file with loop to create graphs for each panel and export (.emf) with consistent naming.

    • Within loop can place panel specific data into macros to make custom titles, reference lines, etc. in the graphs

    • Use xsize() and ysize() to make graphs fit page layout

    • Need to deal with missing data, especially missing graphs (create null graph saying “No Data” using twoway scatteri)

  • Create dataset with 1 observation per panel containing all data/results needed in appendix, formatted as desired

    • Include graph file names as variables in the dataset, or a variable that can be used to construct graph file names, such as id###_g1.emf, id###_g2.emf, etc..

  • outsheet dataset to tab delimited format (readable as mail merge data source)


Specific approach stata5 l.jpg

Specific Approach: Stata

Sample Stata Code

qui levels site, local(sitelist)

foreach site of local sitelist {

...*prepare stuff for graphs

graph ......., saving(`site'_g1.gph, replace)

graph export `site'_g1.emf, replace

graph .........., saving(`site'_g2.gph,replace)

graph export `site'_g2.emf, replace

graph .........., saving(`site'_g3.gph,replace)

graph export `site'_g3.emf, replace

}

outsheet site othervar1 othervar2... using mergedata.txt


Specific approach word processor l.jpg

Specific Approach: Word Processor

Warning: instructions based on MS Word, but word processors and page layout programs not from the evil empire can also do this using slightly different commands

  • Create 1 page layout to hold data and graphs

    • Using tables tends to work well for placement

  • Turn on mail merge toolbar or use “wizard” (in MS Word)

  • Identify .txt file created by outsheet as mail merge data source

  • Insert data from .txt file into proper places in document by using Insert->Field->Mergefield

  • Insert graphs using Insert->Field->Includepicture and grab any picture file (.emf file) (use // and enclose in quotes when typing)

  • Key Trick: edit IncludePicture field to make it work from mail merge

    • Use alt-F9 to toggle view of field codes

    • insert Mergefield within IncludePicture field to create graph file name:

      {INCLUDEPICTURE "../../DATA/MYGRAPHS/{MERGEFIELD "sitename"}_g1.emf"}


Inserting data code l.jpg

Inserting Data: Code


Inserting graphs code l.jpg

Inserting Graphs: code


Inserting data results l.jpg

Inserting Data: Results


Inserting graphs results l.jpg

Inserting Graphs: Results


It worked l.jpg

It worked…

- didn’t take long to set up- very fast to update and revise as needed/wanted


  • Login