Bookmark and Share

Notice: On April 23, 2014, Statalist moved from an email list to a forum, based at statalist.org.


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

Re: st: -project-: tidy position of build directives


From   Robert Picard <[email protected]>
To   "[email protected]" <[email protected]>
Subject   Re: st: -project-: tidy position of build directives
Date   Thu, 29 Aug 2013 18:19:08 +0200

I'm not sure what you mean by "tidiest". Strictly speaking, it doesn't
matter where you put your build directives except of course for
-project, creates()- which must be placed after the command that
creates the file. You could therefore put all build directives that
indicate do-file dependencies at the very end of the do-file.

Personally, I always put my build directives as close as possible to
when the files are accessed. It seems there is a bit less chance of
forgetting a directive that way. After a little while, this becomes a
habit. In most cases, there's no need to use the -preserve- option
since the data in memory is usually cleared when the file is accessed.
So my do-files look like:

project, original("raw.txt")
insheet using "raw.txt")
...
save "raw.dta"
project, creates("raw.dta")

In another do-file, I could have

project, uses("raw.dta")
project, uses("cpi.dta")
use "raw.dta"
merge m:1 year using "cpi.dta")

The above is preferable to

project, uses("raw.dta")
use "raw.dta"
project, uses("cpi.dta") preserve
merge m:1 year using "cpi.dta")

for the obvious reason that saving the data in memory using -preserve-
requires extra work that can be easily avoided by moving-up the second
-project, uses()- directive. So generally, I put my directives as
close as possible to where the file is accessed but rarely use
-preserve-. Note that you only need to declare a dependency once per
file accessed in a do-file. So if you load "raw.dta" 3 separate times,
you only need to issue one -project, uses("raw.dta").



On Thu, Aug 29, 2013 at 2:29 PM, Meisfjord, Jørgen Rajan
<[email protected]> wrote:
> Regarding the user-written package -project- by Robert Picard and installed using:
>
>   net from http://robertpicard.com/stata
>
> Could someone tell me what tends to be the tidiest way to declare the build directives
>       -project, uses(uses_file)- and
>       -project, original(original_file)-,
> in a do-file, -all of them at the top of the do-file, or spread out at the positions in the do-file where the uses_files and original_files are being opened/merged in/imported?
>
> Thanks.
>
> Jørgen Meisfjord
> Stata 12.1 SE (64-bit)
> Dpt. of Health Statistics | Norwegian Institute of Public Health
>
>
> *
> *   For searches and help try:
> *   http://www.stata.com/help.cgi?search
> *   http://www.stata.com/support/faqs/resources/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/faqs/resources/statalist-faq/
*   http://www.ats.ucla.edu/stat/stata/


© Copyright 1996–2018 StataCorp LLC   |   Terms of use   |   Privacy   |   Contact us   |   Site index