Mass producing appendices using stata and word processor mail merge
Download
1 / 11

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


  • 233 Views
  • Uploaded on

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

loader
I am the owner, or an agent authorized to act on behalf of the owner, of the copyrighted work described.
capcha
Download Presentation

PowerPoint Slideshow about 'Mass producing appendices using Stata and word processor mail merge' - jaden


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 mail merge

  • 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 mail merge

  • 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 mail merge

  • 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 mail merge

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 mail merge

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"}






It worked l.jpg
It worked… mail merge

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