help for do2screen <v 3.0>

Syntax

do2screen [using/], [ Options ]

Sections

Sections are presented under the following headings:

Command description
Options description
Examples

Options

Display option
variables(string) Select variables to analyze. May not be combined with
find or range options.

find(s1) Look for s1 in the do-file. By default, do2screen displays the
subsequent 5 lines to the line in which s1 is found.

range(numlist min=1 max=2) Displays specified range of code lines.

lines(integer) Number of lines after first finding using find option. Default 5 lines.

noprevious Suppress display of previous variables.

lables Show creation of labels of variables.

Specification
folder(string) Directory path in which do-file/ is/are located. Default current directory

Export
text(string) Name and path of text file to save results.

replace Replace existing text file.

Advanced
lrep Left quote handle (`). default LlLl

rrep Right quote handle ('). default RrRr

dblq Double quote handle (""). default DQDQ

scalarname(string) Scalar name with returned output. Default is s_varcode

comments Include comments on code. By default do2screen supresses comments but it makes the process slower. Use this option to speed up process but probably with undesired results.

nolinenumbers Supress line number from output. programers option

Description

do2screen is a Stata package that allows the user to review specific sections
of a particular do-file, or set of do-files, directly in the Stata screen. do2screen
has three functionalities. i) It displays the specific lines of code in which a particular
variable is created, modified, or dropped during a routine. In this version of
do2screen, the creation of previous variables are displayed. ii) It displays all the code
in which a specific string is located and, by default, it shows the subsequent 5 lines
of code. The user can change the number of subsequent lines to display. iii) It displays
a specific section of the do-file by selecting the range of lines of code that are desired
to be analyzed.

The basic idea behind do2screen is to take advantage of all the information
contained in the do-files for specific project. It is common to find yourself with a
thousand-line script in which a single variable is used in several sections of the do-file
and it is not always easy to track its development throughout the routine. Additionally,
do2screen is able to find interactions of a variable across do-file. Thus, you can
know where your variable under analysis is being used or modified in several do-files of the
same project.

Whenever you search for a specific do file, do2screen will allow you open the file
just clicking the Open link.

Options description

Display option

variables(string) Select variables to analyze. More than one variable is allowed. It may not be combined with find or
range.

find(s1) It is possible to look for any word or sentence within the do-file.
In order to specify a sentences and separate them from each other, make sure you are using
double compound quotes (`" "'). For example, you can differentiate the search of
"Creation of income variables" from the single word "income" by specifying
find(`" "Creation of income variables" income "'). Take into account that to find specific senteces,
you need to embraced them with double quotes ("") inside the double component quotes (`""'). For instance,
find(`"Creation of income variables"') won't find the sentence "Creation of income variables" rather
each word separately i.e. Creation, of, income, and variables. Therefore the proper way
is to type find(`" "Creation of income variables" "')

range(numlist min=1 max=2) Range option may be used in two different ways.

i) Select the line number in which the analysis it's going to start and ii) specify how many lines
ahead should be displayed. for example, do2scree[...], range(253) lines(10) will display the code lines
of a certain do-file from line 253 to line 263 because 10 lines ahead was specified.
If 'lines' is not specified do2screen will analyze the following five
lines.

ii) Specify the range of analysis by typing the starting and ending lines.
The example above will display the same results if you type do2scree[...], range(253 263)

noprevious Suppress display of previous variables. By default, do2screen
displays the whole procedure for creating a particular variable. For example, if
variable a is created as gen a = b + c, do2screen will identify not only
the creation of a, but also the creation of b and c. Option
noprevious suppress the creation of b and c and only display the creation
of a. In case b and c are not original variables (i.e are not created
within the do-file), do2screen will display the creation of any variable needed
for the creation of b and c and will do the same over and over again until
it reaches only original variables. That is, the output of do2screen allows
the user to reconstruct a variable from the beginning of the do-file regardless
of it order in the do-file.

labels By default, do2screen does not display any line of the do-file that
creates or modifies variables labels. Option labels allows the user to see the
creation of any label; label var..., label define..., or label values....

Specifications

using specifies name of do-file to be analyzed. If no directory path is provided,
do2screen will search do-file name in current directory. see examples
below

folder(dir path) will analyze do-file specified in using syntax. If no do-file
name is specified in using, do2screen will analyze all do-files contained in dir path.
Therefore,

do2screen using test.do, folder(C:\mydata)

is equivalent to

do2screen using "C:\mydata\test.do"

Export

text(string) name of text-file displayed results of do2screen. If no path is
specified, text-file will be saved in current directory. For instance, text(C:\mydata\example)
will save file example.txt in folder C:\mydata\

replace Replace existing text-file.

Advanced

lrep, rrep, dblq. lrep Left quote handle (`). default LlLl.
rrep Right quote handle ('). default RrRr. dblq Double quote handle ("").
default DQDQ. Given that do2screen reads do-files and display them on the screen,
it needs to handle quotes in sufch a way that Stata do not interpret them as real local
macros or strings. Thus, uring the process, do2screen replace each quote to the
corresponding handle and replace it back at the end of the do-file. Use this option
only if the default handles are actually in used in your code so that when the
replacement is done back again, it will mess up your code.

comments By default, do2screen do not project any comment from your
code in the result window because it assumes that you only want to see real code.
However, removing all comments from a Stata script a lot of computational power.
If you are interested in see your comments or/and speed up the process. Uses this option.

Examples

Variables

i) Look for variables "weight" and "expenditure" in a specific Do-file in current directory

do2screen using "test.do", var( weight expenditure )

ii) Look for variables "weight" and "expenditure" in a specific Do-file in "C:\mydata\" directory

do2screen using "C:\mydata\test.do", var( weight expenditure )

iii) Look for variables "weight" and "expenditure" in all available do-files in current directory

do2screen, var( weight expenditure)

iv) Look for variables "weight" and "expenditure" in a specific Folder
(it will search in all available do-files)

do2screen , var( weight expenditure ) folder("C:\Users")

Find

i) Look for the word "Poverty"

do2screen using "test.do", find("Poverty")

ii) Look for the word "Poverty" and specify how many lines, after the word, should
be shown (default 5 lines)

do2screen using "test.do", find("Poverty") lines(10)

iii) Look for the phrase "Poverty and Inequality" on one hand, and "Severity", on
the other hand

do2screen using "test.do", find(`" "poverty and inequality" severity"')

Range

i) Specify a Range to be shown in the result screen

do2screen using "test.do", range(10 30)

ii) Specify and initial line and the amount of lines to be displayed

do2screen using "test.do", range(10) lines(10)

Export Results

i) Export results to a text file (.txt)

do2screen using "test.do", var( weight expenditure ) text("text_file")

ii) Export results to a text file (.txt) and replace existing txt file.

do2screen using "test.do", var( weight expenditure ) text("text_file") replace

Saved Results

By default, do2screen saves the retrieved code in the scalar
s_varcode. If you have this name in used already, please use option scalarname.

Authors

Santiago Garriga, The World Bank

Email santiago.garriga@psestudent.eu

Email garrigasantiago@gmail.com

R.Andres Castaneda, The World Bank

Email acastanedaa@worldbank.org

Email r.andres.castaneda@gmail.com