Notice: On March 31, it was **announced** that Statalist is moving from an email list to a **forum**. The old list will shut down on April 23, and its replacement, **statalist.org** is already up and running.

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

From |
Nick Cox <n.j.cox@durham.ac.uk> |

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

Subject |
RE: st: using foreach in regression models - combing graphs from the different variables |

Date |
Tue, 25 Oct 2011 15:48:55 +0100 |

There are various problems here, if I understand you correctly. One is that the -graph combine- statement must be outside the -foreach- loop and not inside it. A second is that you are just asking -graph combine- to work on one graph, so it is not at all surprising that this does not work. A third is that -graph combine- will not work on *.png! A way forward is to accumulate filenames within the loop so that you have a statement something like local files `files' `"<details of new file each time round the loop>"' and then outside the loop you go graph combine `files' In essence, you have to name the files, or equivalently the graphs, to be -combine-d. This is quite explicit in the help. I see here only code that if corrected would produce 4 graphs. It's no doubt a generational thing, but I would never put spaces in filenames in Windows, even though it's allowed, as it's more likely to bite me than to benefit me. I see here "C:\TEST \" and "C:\Test\"; I don't know how Windows would react to that. .png as final thing to be exported is your concern. Nick n.j.cox@durham.ac.uk Tim Evans I have modified my regression commands in order that I can loop through the variables and graph them. I'm stuck on how to use graph combine to combine these graphs into one page (5 graphs on each page), following on the from the loop as follows: BEGIN CODE loc covariates "i.NRCENT i.site__4 sex i.id07 i.yydx" foreach var of varlist agegrp id07 NRCENT site__4 { di as text "Does `var' affect you getting surgery (any from HES) (Adjusted)" cap noi logistic everrcsurgeryhes2 i.`var' `covariates' preserve qui do "C:\TEST \labelling" /* */ "O/R of surgery (any from HES) (`var')" qui graph export "C:\Test\Adjusted_`var'_surgery (any from HES).png", replace restore di as text "End of Does `var' affect you getting surgery (any from HES) (Adjusted)" graph combine "C:\Test\Unadjusted_`var'_ any surgery from HES.png" ****THIS DID NOT WORK*** } I don't know whether I can use regexm to say the filename begins with 'Unadjusted' and ends with 'from HES' and incorporate this into the graph combine, but essentially I don't explicitly name the graphs as they are stored and don't want to name them explicitly (by this I mean type each one out as I may in future add more to my varlist). I'm assuming I will have to save as .gph before saving the final version as a png if that's my chosen format? * * 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: R: variable not found?***From:*"Carlo Lazzaro" <carlo.lazzaro@tin.it>

**Re: st: R: variable not found?***From:*Christian Otchia <bensamen@gmail.com>

**RE: st: R: variable not found?***From:*Nick Cox <n.j.cox@durham.ac.uk>

**st: using encode to order string distances***From:*Tim Evans <Tim.Evans@wmciu.nhs.uk>

**st: RE: using encode to order string distances***From:*Nick Cox <n.j.cox@durham.ac.uk>

**st: using foreach in regression models***From:*Tim Evans <Tim.Evans@wmciu.nhs.uk>

**RE: st: using foreach in regression models***From:*Tim Evans <Tim.Evans@wmciu.nhs.uk>

**RE: st: using foreach in regression models - combing graphs from the different variables***From:*Tim Evans <Tim.Evans@wmciu.nhs.uk>

- Prev by Date:
**Re: st: reoprob claims to have no observations** - Next by Date:
**RE: st: using foreach in regression models - combing graphs from the different variables** - Previous by thread:
**RE: st: using foreach in regression models - combing graphs from the different variables** - Next by thread:
**RE: st: using foreach in regression models - combing graphs from the different variables** - Index(es):