STATA 11 for Windows SAMPLE SESSION - Food Security Group ...
STATA 11 for Windows SAMPLE SESSION - Food Security Group ...
STATA 11 for Windows SAMPLE SESSION - Food Security Group ...
Create successful ePaper yourself
Turn your PDF publications into a flip-book with our unique Google optimized e-Paper software.
Stata <strong>11</strong> Sample Session Annex I I– Survey Instrument<br />
hh animcode num<br />
206 331 70<br />
217 331 65<br />
217 335 8<br />
221 330 1200<br />
221 331 200<br />
The above file could have been organized such that each household has only one line of in<strong>for</strong>mation, and<br />
the three animal types appear as three different variables. Such a file would be the wide <strong>for</strong>m of the data.<br />
The file as it is organized now is the long <strong>for</strong>m of the data.<br />
The following reshape command converts the file from long to wide <strong>for</strong>m such that each animal code is<br />
now a variable, and the file becomes a household-level file.<br />
. reshape wide num, i (hh) j (animcode)<br />
. list, nol nod noo<br />
hh num330 num331 num335<br />
206 . 70 .<br />
217 . 65 8<br />
221 1200 200 .<br />
When followed by this next command, the file is re-converted from wide to long. But note that the file<br />
has become rectangularized, that is, the three animal codes now appear <strong>for</strong> each household.<br />
. reshape long num, i (hh) j (animcode)<br />
. list, nol nod noo<br />
hh animcode num<br />
206 330 .<br />
206 331 70<br />
206 335 .<br />
217 330 .<br />
217 331 65<br />
217 335 8<br />
221 330 1200<br />
221 331 200<br />
221 335 .<br />
The command fillin would have also generated the same rectangularized file as in the preceding example.<br />
Do-file suggested commands to place at the beginning of a do-file to set the parameters be<strong>for</strong>e starting to work:<br />
1. Commands in a do-file may be delimited by a carriage return or a semi-colon. To set the semi-colon as<br />
the delimiter, the command is:<br />
#delimit ;<br />
This command will only work in a do-file. The delimiter cannot be changed<br />
from the console.<br />
If you wish to revert back to the carriage return as the delimiter, the command is:<br />
#delimit cr<br />
2. The next command will clear the memory:<br />
clear all;<br />
3. There are several “set” commands that are useful to put at the beginning of the do-file as well.<br />
set memory 70000; (sets the size of memory)<br />
set matsize 100 ; (limits number of variables that can be specified in an estimation command)<br />
<strong>11</strong>6