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]

st: byable program speed performance on statamp


From   Chris Parker <[email protected]>
To   [email protected]
Subject   st: byable program speed performance on statamp
Date   Fri, 6 May 2011 15:50:25 +0100

Hello,

Sorry if this is an obvious question, but I have been looking online
with no luck. I am using StataMP/4 version 11.2. I have daily data for
crops and markets that I am trying to combine with data on individuals
who have subscribed to a price information service for that crop and
market. However both datasets are very large and even with 16GB of
memory I can't do a single joinby call. I therefore wrote a loop to
perform the joinby and process the data for each crop market and
create individual dta files which I will then append at the end (see
below). If I write this as a byable program and then execute it, will
I run on all 4 cores on my computer?

levelsof cropmarket, local(levels)

foreach tempArg of local levels {
	preserve
	keep if cropmarket ==`tempArg'
	decode cropmarket, gen(cropmarketstr)
	joinby cropmarketstr using subscriptiondata, unmatched(master)
	drop cropmarketstr

	* Find out which subscriptions are active
	gen active =cond((date>=startdate) & (date<=enddate),1,0)

	* find out how many active subscriptions there are
	bysort crop market date: egen numsubscriptions= total(active)

	* Need to keep the active subscription data points plus one price
point with no active subscriptions
	egen tag = tag(crop market date)
	drop if (numsubscriptions==0)& missing(tag)
	drop if (numsubscriptions>0)&(active==0)

	drop active tag startdate enddate subscriptionstate
	
	save t`tempArg'
	
	restore
}

Thanks!
Chris


Chris Parker

________________________________

PhD Candidate | Management Science & Operations
London Business School | Regent's Park | London NW1 4SA | United Kingdom
Direct line +44 (0)20 7000 8816 | Email [email protected]
*
*   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–2018 StataCorp LLC   |   Terms of use   |   Privacy   |   Contact us   |   Site index