[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

From |
"Amanda Rose" <amgrose@lightspeed.net> |

To |
<statalist@hsphsun2.harvard.edu> |

Subject |
st: Re: Re: programming graphical report |

Date |
Thu, 13 Nov 2008 08:32:44 -0800 |

Amanda

To: <statalist@hsphsun2.harvard.edu> Sent: Thursday, November 13, 2008 5:19 AM Subject: st: Re: programming graphical report

Friedrich Huebler responded with example code (see below) to my request toproduce and store a long series of graphs for import into another packagefor a report. After some playing with the code to meet my specificrequirements, the code does exactly what I needed.Thanks to Friedrich for his expert help. Steve Rothenberg CINVESTAV MexicoSteve,Here is an example to get you started. It shows how to loop over departments and individuals and how to name the graphs. The first four lines set up the data. The part you are interested in starts with -levelsof-. sysuse auto, clear bysort foreign: keep if _n<3 rename make name decode foreign, gen(dept) levelsof dept, local(depts) levelsof name, local(names) foreach d of local depts { foreach n of local names { capture graph bar mpg /// if dept=="`d'" & name=="`n'", /// title("`d', `n'") if _rc==0 { graph export "`d', `n'.emf" } } } Friedrich----- Original Message -----From: "Steve" <drlead@prodigy.net.mx>To: <statalist@hsphsun2.harvard.edu> Sent: Friday, November 07, 2008 6:26 PM Subject: programming graphical reportListers:I've been asked to produce a report of an evaluation of an institutiondivided into some 20 separate departments each with approximately 30individuals (variable number in each department). The data are arrangedwide, with a string ID variable (individual name), a string departmentvariable, and three numeric variables for the evaluation scales.The report will be strictly graphical and its purpose is to place eachindividual on a cumulative summary of each department's ratings on threescales. Thus I calculate the cumulative proportions of each scale foreach department by. by dept, sort : cumul desemp, generate(desacum) equal . by dept, sort : cumul cond, generate(condacum) equal etc. I've manually generated the basic graph example with:. twoway line desac desemp if dept=="1A", sort || scatter desacum desempin 4, msize(large)This gives me a line plot with proportion of responses in the departmenton the y-axis and the ratings for a scale on the x-axis with the lineshowing the cumulative plot (first part of command); it also gives me anindividual's scale score (from the fourth line of the data set), plottedas a large dot on the line (second part).The present graph code uses a hardcoded -if- statement to restrict theplotting of the cumulative response to one department and ahard-coded -in- statement to pull the individual's score on that ratingscale and plot it on the cumulative line for his department drawn by thefirst part of the command.I want to go on to the second and third rating scales for that departmentand individual and use -graph combine- to produce a matrix of thecumulative ratings for that department and individual in the format:X X Xand do the same for each individual in that department, each timeproducing the graphical matrix for each individual. Then (or right aftereach -graph combine-), store the graphical matrix in an enhanced windowmetafile for import into a Word page, with the name of the .emf file acomposite of the two letter department name and the first 10 letters ofthe subject ID (with spaces) for that matrix.With over 600 individuals, it's clear it should not be done by hand.After exhausting the individuals in the first department, the programshould move on to the next departments and groups of individuals,producing a one page graphic matrix for each individual.I've read sections of the User and Programming manuals on loops andmacros, but can't figure out how to do the double indexing that's needed,nor to assign file names of output using parts of the two stringvariables for ID and department.I'm using a Vista Windows machine, Stata MP 10.1, 2 GBytes memory. Steve Rothenberg CINVESTAV Mexico* * For searches and help try: * http://www.stata.com/help.cgi?search * http://www.stata.com/support/statalist/faq * http://www.ats.ucla.edu/stat/stata/

* * For searches and help try: * http://www.stata.com/help.cgi?search * http://www.stata.com/support/statalist/faq * http://www.ats.ucla.edu/stat/stata/

**References**:**st: Re: programming graphical report***From:*"Steve" <drlead@prodigy.net.mx>

- Prev by Date:
**Re: st: Latest version of -plotmatrix-** - Next by Date:
**Re: st: Latest version of -plotmatrix-** - Previous by thread:
**st: Re: programming graphical report** - Next by thread:
**st: predictions after clogit** - Index(es):

© Copyright 1996–2022 StataCorp LLC | Terms of use | Privacy | Contact us | What's new | Site index |