UCLA Academic Technology Services HomeServicesClassesContactJobs
Search

Stata Code Fragment: 
Using and saving graphs in Stata in Batch Mode

* lets start with a tiny file
clear
input id y80 y81
1  5  6
2 10 11
3 15 16
4  3  4
end

* if running in batch mode, the following graph will do nothing
graph twoway scatter y80 y81

* You can use the "saving" option to save it as a file
* the following example saves it as "hist.gph"
* ONLY stata can read and use .gph files
graph twoway scatter y80 y81, saving(hist)

* if I try to save the same graph again, I must use the replace option
* for example, if I run this program again, the above command would 
* fail.  To ask stata to overwrite the existing graph, use the "replace" option
graph twoway scatter y80 y81, saving(hist, replace)

***************************************************
* once you have run your batch program, you can 
* look at the stata graphs in interactive mode.
* The easiest way to do this is to FTP the .gph files
* to one of the PCs running Stata (e.g. in the lab in A1-242)
* You can FTP the files in BINARY mode and look at them 
* like this within Stata

graph use hist

* and that will show you the graph
For more information, see http://www.stata.com/help.cgi?graph_save and 
http://www.stata.com/help.cgi?graph_use 
 

How to cite this page

Report an error on this page

UCLA Researchers are invited to our Statistical Consulting Services
We recommend others to our list of Other Resources for Statistical Computing Help
These pages are Copyrighted (c) by UCLA Academic Technology Services


The content of this web site should not be construed as an endorsement of any particular web site, book, or software product by the University of California