Introduction to Stata 8 - (GRIPS
Introduction to Stata 8 - (GRIPS
Introduction to Stata 8 - (GRIPS
You also want an ePaper? Increase the reach of your titles
YUMPU automatically turns print PDFs into web optimized ePapers that Google loves.
15. Miscellaneous<br />
15.1. Memory considerations [U] 7<br />
In Intercooled <strong>Stata</strong> a data set can have a maximum of 2,000 variables (<strong>Stata</strong>/SE: 32,000).<br />
<strong>Stata</strong> keeps the entire data set in memory, and the number of observations is limited by the<br />
memory allocated. The memory must be allocated before you open (use) a data set.<br />
As described in section 1.2 the initial default memory is defined in the <strong>Stata</strong> icon. To change<br />
this <strong>to</strong> 15 MB, right-click the icon, select Properties, and change the path field text <strong>to</strong>:<br />
c:\stata\wstata.exe /m15.<br />
If the memory allocated is insufficient you get the message:<br />
no room <strong>to</strong> add more observations<br />
You may increase the current memory <strong>to</strong> 25 MB by:<br />
clear // You can't change memory size with data in memory<br />
set memory 25m<br />
You can see the amount of used and free memory by:<br />
memory<br />
compress [R] compress<br />
To reduce the physical size of your data set – and the memory requirements – <strong>Stata</strong> can<br />
determine the fewest bytes needed for each variable (see section 6.2), and you can safely:<br />
compress<br />
and save the data again (save... , replace). This may reduce the memory need by 80%.<br />
Handling huge data sets<br />
If you are regularly handling huge data sets you may consider:<br />
• <strong>to</strong> use compress <strong>to</strong> reduce memory requirements<br />
• <strong>to</strong> increase your computer's RAM (not expensive)<br />
For instance with 512 Mb RAM you could set memory 400m for <strong>Stata</strong>, and this would fit<br />
very large data sets, e.g. a million observations with 100 variables. <strong>Stata</strong>/SE can handle up <strong>to</strong><br />
32,000 variables, but memory restrictions otherwise don't differ from Intercooled <strong>Stata</strong>. SAS<br />
or SPSS might be alternatives.<br />
You might not be able <strong>to</strong> create the entire <strong>Stata</strong> data set because of its hugeness. Try <strong>to</strong> read<br />
one part of the data, compress and save, read the next part of the data, compress and save,<br />
etc., and finally combine (append) the partial data sets (see section 10.6):<br />
/ / c:\dokumenter\p1\gen.aa.do<br />
infix id 1 type 2 sold 4-7 using c:\dokumenter\p1\aa.txt in 1/10000<br />
compress<br />
save c:\tmp\aa1.dta<br />
infix id 1 type 2 sold 4-7 using c:\dokumenter\p1\aa.txt in 10001/20000<br />
compress<br />
append using c:\tmp\aa1.dta<br />
save c:\dokumenter\p1\aa.dta<br />
54