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 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]

st: Makefiles that uses do files to build data sets runs several do files every time?


From   Ricardo Altamirano <pythsc@gmail.com>
To   statalist@hsphsun2.harvard.edu
Subject   st: Makefiles that uses do files to build data sets runs several do files every time?
Date   Mon, 18 Feb 2013 11:39:33 -0600

Dear Statalist,

I'm using a makefile to run a group of Stata files that process raw
datasets stored in several directories and merge them into a single
data set. Each time I run the makefile, it builds the majority of the
files (specifically, it runs raw4.do through raw12.do), even if I run
make back to back without making any changes. Is there an error in my
makefile, or am I misunderstanding how to use a makefile with Stata
(which very well could be the case)?

These are the contents of the makefile:

        .PHONY: clean

	STATACOMMAND=/usr/local/stata/stata-mp -b

	# Main target
	analysis.txt: analysis.do dta/finaldata.dta
	    $(STATA) analysis.do
	    mv *.log logs/

	dta/finaldata.dta:  raw11.do dta/raw8.dta dta/raw9.dta dta/raw10b.dta
	    $(STATA) raw11.do

	dta/raw10b.dta: dta/raw10a.dta ;

	dta/raw10a.dta: raw10.do raw10datasource/%.txt
	    $(STATA) raw10.do

	raw10datasource/%.txt: ;

	dta/raw9.dta: raw9.do raw9datasource/raw9.dct raw9datasource/raw9.txt
	    $(STATA) raw9.do

	raw9datasource/raw9.dct raw9datasource/raw9.txt: ;

	dta/raw8.dta: raw8.do dta/raw7.dta dta/raw5.dta:
	    $(STATA) raw8.do

	dta/raw7.dta: raw7.do dta/raw6.dta
	    $(STATA) raw7.do

	dta/raw6.dta: raw6.do raw6datasource/%.xls
	    $(STATA) raw6.do

	raw6datasource/%.xls: ;

	dta/raw5.dta: raw5.do dta/raw4b.dta dta/raw3.dta
	    $(STATA) raw5.do

	dta/raw4a.dta dta/raw4b.dta: raw4.do raw4datasource/ftp/%.csv
	    $(STATA) raw4.do

	raw4datasource/ftp/%.csv: ;

	dta/raw3.dta: raw3.do raw3datasource/ftp/raw3.txt raw3datasource/ftp/raw3.dct
	    $(STATA) raw3.do

	raw3datasource/ftp/raw3.dct: ;
	raw3datasource/ftp/raw3.txt: ;

	dta/raw2.dta: dta/raw1.dta raw2.do
	    $(STATA) raw2.do

	dta/raw1.dta: raw1.do raw1datasource/%.txt
	    $(STATA) raw1.do

	raw1datasource/%.txt: ;

	clean:
	    -rm *.log

Thank you,

Ricardo A.
*
*   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–2014 StataCorp LP   |   Terms of use   |   Privacy   |   Contact us   |   Site index