Bookmark and Share

Notice: On March 31, it was announced that Statalist is moving from an email list to a forum. The old list will shut down at the end of May, and its replacement, statalist.org is already up and running.


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

Re: st: saving graph with a unique filename


From   Eric Booth <eric.a.booth@gmail.com>
To   statalist@hsphsun2.harvard.edu
Subject   Re: st: saving graph with a unique filename
Date   Fri, 20 Apr 2012 12:27:55 -0500

<>

> 
> is how do you do it? if args was a marco, then I could have said
> 
> 
> tsline hits, saving(`args', replace)
> 
> but, args isn't. Is there any way to have strings in arguments as filename and if there are other ways to create a unique file, please share…


Yes, start and end dates are macros after -args-
instead of your code, run this:

> tsline hits, saving(`startdate'`enddate', replace)



- Eric

__
Eric A. Booth
Public Policy Research Institute 
Texas A&M University
ebooth@ppri.tamu.edu
+979.845.6754

On Apr 20, 2012, at 12:19 PM, tashi lama wrote:

> Hello all, 
> 
>            I have a do file as follows
> 
> 
> 
> /* begin example.do */
> 
> args start_date end_date
> 
> odbc query rr 
> 
> odbc load,exec("select distinct read_date as date, count(*) as hits from table1 where read_date between `start_date' and `end_date' group by read_date")
> 
> tsset date 
> 
> list
> 
> tsline hits, saving(*, replace)
> 
> 
> 
> 
> 
> when you run             
> 
> do example 01jan2010 03jan2010, you will get 
> 
> 
> 
> 
> 
>  date                 hits
> 
> 01jan2010               4
> 
> 02jan2010               5
> 
> 03jan2010               9
> 
> 
> 
> 
> 
> and of course the line graph. I would like to save the graph as a unique filename everytime I run it. One way I could think of doing that is save the graph with strings in the args as a filename. So, 
> 
> the graph in the example will be saved as 01jan201003jan2010.gph and if you run the stata like do example 01jan2011 31dec2011, the graph will be saved as 01jan201131dec2011.gph and etc...The problem 
> 
> is how do you do it? if args was a marco, then I could have said
> 
> 
> 
> tsline hits, saving(`args', replace)
> 
> but, args isn't. Is there any way to have strings in arguments as filename and if there are other ways to create a unique file, please share...
> 
> 
> 
> Thank you, 
> 
> Tashi  
> 
> 
> 
>  		 	   		  
> *
> *   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/


© Copyright 1996–2014 StataCorp LP   |   Terms of use   |   Privacy   |   Contact us   |   Site index