Bookmark and Share

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

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

st: byable program speed performance on statamp

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


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 {
	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'


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
*   For searches and help try:

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