Stata The Stata listserver
[Date Prev][Date Next][Thread Prev][Thread Next][Date index][Thread index]

Re: st: Recode slow


From   Brendan Halpin <brendan.halpin@ul.ie>
To   statalist@hsphsun2.harvard.edu
Subject   Re: st: Recode slow
Date   28 Oct 2005 14:14:25 +0100

Brendan Halpin wrote:

> Is it normal that recode should be very slow with large numbers of
> "rules"? I find a recode statement with >400 value assignments adds
> something of the order of a minute to a job.
>
> N is moderately large (75k) but I wonder if recode is linear in N
> but non-linear in the number of rules or assignments.
>
> If so, any tips for efficiency? Break up the command into several
> smaller recodes? Ship out the equivalences to a lookup table and
> merge?

Just to follow myself up: I succumbed to that temptation described
by Douglas Adams as spending half a day coding something to save
thirty seconds, and switched the big recode to a lookup table.

In running time, the merge lookup (along with necessary sorts etc)
takes under 4 seconds (c 150k cases, >400 categories reassigned).
The recode version takes over 3 minutes to do the same. 

So in fact I spent about half an hour to save about 2m55!

Brendan
-- 
Brendan Halpin,  Department of Sociology,  University of Limerick,  Ireland
Tel: w +353-61-213147 f +353-61-202569 h +353-61-338562; Room F2-025 x 3147
mailto:brendan.halpin@ul.ie  http://www.ul.ie/sociology/brendan.halpin.html
*
*   For searches and help try:
*   http://www.stata.com/support/faqs/res/findit.html
*   http://www.stata.com/support/statalist/faq
*   http://www.ats.ucla.edu/stat/stata/



© Copyright 1996–2014 StataCorp LP   |   Terms of use   |   Privacy   |   Contact us   |   What's new   |   Site index