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 |
Tim Evans <Tim.Evans@wmciu.nhs.uk> |

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

Subject |
st: RE: RE: RE: Removing multiple files in a directory - clean-up |

Date |
Fri, 2 Dec 2011 14:10:04 +0000 |

Thanks for the responses. I like both solutions. Best wishes Tim -----Original Message----- From: owner-statalist@hsphsun2.harvard.edu [mailto:owner-statalist@hsphsun2.harvard.edu] On Behalf Of MacLennan, Graeme Sent: 02 December 2011 13:03 To: 'statalist@hsphsun2.harvard.edu' Subject: st: RE: RE: Removing multiple files in a directory - clean-up Tim, I use the following to create, use, then clear a temp folder (for example a storing area for resultssets to get concatenated and written to latex for presentation): *** begin example*** mkdir C:\test1\analysis\temp cd C:\test1\analysis\temp * your code here clear cd C:\test1\analysis !rmdir C:\test1\analysis\temp /s /q *** end example*** The /q option forces the clear, if you use just the /s option you'll get asked if you are sure. HTH, Graeme. -----Original Message----- From: owner-statalist@hsphsun2.harvard.edu [mailto:owner-statalist@hsphsun2.harvard.edu] On Behalf Of Tim Evans Sent: 02 December 2011 10:55 To: 'statalist@hsphsun2.harvard.edu' Subject: st: RE: Removing multiple files in a directory - clean-up Hi all, Actually, think I may have solved this myself using the following (though happy to learn of a neater way if it exists): **BEGIN CODE** local workdir "C:\test1\analysis" cd `workdir' local datafiles: dir "`workdir'" files "*.dta" foreach datafile of local datafiles { rm `datafile' } **END CODE** Best wishes Tim -----Original Message----- From: owner-statalist@hsphsun2.harvard.edu [mailto:owner-statalist@hsphsun2.harvard.edu] On Behalf Of Tim Evans Sent: 02 December 2011 10:02 To: 'statalist@hsphsun2.harvard.edu' Subject: st: Removing multiple files in a directory - clean-up I am using Stata 11.2 and am looking for a routine that will look for all of the .dta files in my specified directory and remove them once I have completed my analysis as a clean-up exercise. I am using the code below after I have run my regression analysis, to list and combine my datafiles created following the regression analysis, but I cant seem to find out how I can remove all of the unwanted .dta files after I have exported the master analysis as a .csv file. This is important as I will then go on to use the code below after another set of regressions saved in the same directory, and I don't want to combine regression results from different sets of analysis. Is there a way I can amend the code below to remove all the files: BEGIN CODE: cd c:\test1 ! dir *.dta /a-d /b >c:\test1\filelist.txt file open myfile using c:\test1\filelist.txt, read file read myfile line use `line' save master_data, replace file read myfile line while r(eof)==0 { /* while you're not at the end of the file */ append using `line' file read myfile line } file close myfile sort label2 analysis rename estimate odds_ratio drop order axis order label2 analysis odds_ratio min95 max95 stderr z p flag parm save master_data, replace rm c:\test1\filelist.txt outsheet using C:\test1\results\Section1.csv,c replace END CODE Best wishes Tim _DISCLAIMER: This email and any attachments hereto contains proprietary information, some or all of which may be confidential or legally privileged. It is for the exclusive use of the intended recipient(s) only. If an addressing or transmission error has misdirected this e-mail and you are not the intended recipient(s), please notify the author by replying to this e-mail. If you are not the intended recipient you must not use, disclose, distribute, copy, print, or rely on this e-mail or any attachments, as this may be unlawful. * * 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/ _DISCLAIMER: This email and any attachments hereto contains proprietary information, some or all of which may be confidential or legally privileged. It is for the exclusive use of the intended recipient(s) only. If an addressing or transmission error has misdirected this e-mail and you are not the intended recipient(s), please notify the author by replying to this e-mail. If you are not the intended recipient you must not use, disclose, distribute, copy, print, or rely on this e-mail or any attachments, as this may be unlawful. * * 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/ The University of Aberdeen is a charity registered in Scotland, No SC013683. * * 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/ _DISCLAIMER: This email and any attachments hereto contains proprietary information, some or all of which may be confidential or legally privileged. It is for the exclusive use of the intended recipient(s) only. If an addressing or transmission error has misdirected this e-mail and you are not the intended recipient(s), please notify the author by replying to this e-mail. If you are not the intended recipient you must not use, disclose, distribute, copy, print, or rely on this e-mail or any attachments, as this may be unlawful. * * 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: Ratio of coefficients from two regressions and standard error.***From:*meenakshi beri <berimeenakshi@hotmail.com>

**st: RE: Removing multiple files in a directory - clean-up***From:*Tim Evans <Tim.Evans@wmciu.nhs.uk>

- Prev by Date:
**st: 'Observations differ'** - Next by Date:
**st: 'Observations differ'** - Previous by thread:
**st: RE: RE: Removing multiple files in a directory - clean-up** - Next by thread:
**st: Is it possible to specify a baseline category without -xi:-** - Index(es):