SDA 4.1 Documentation for LISTCASE


listcase - List values of individual cases


listcase -b batch_filename
listcase -options (for command-line version)


LISTCASE is a program to produce a case-by-case listing of the values of a specified set of variables. One or more filter variables can be used, in order to limit the listing to a subset of the cases in the dataset.

All selected cases are listed, including those with missing-data codes. However, the missing-data codes are not included in the calculation of summary statistics, if statistics are requested.



In addition to (or instead of) displaying the values of variables, it is possible to calculate and display the percent of one variable divided by another variable. (Both variables must be numeric variables.) This is particularly useful when some of the variables in the data file represent aggregate units such as cities.

To calculate and display a percent, use the following formats, beginning with $p, when specifying the variables to be listed:

$p(var1, var2)
This will display the value: 100 * var1 / var2
(using 1 decimal place) where 'var1' and 'var2' are variables in the dataset. It is not necessary that either 'var1' or 'var2' be specified separately for listing.

$p(var1, var2, 2)
To display a percent using other than one decimal place, specify the desired number of decimal places after var2. The example above would use 2 decimal places.

$p(demo, totvote, "Percent democratic")
To give your own name to the percentage created, put the name you want within double quotes. This name will be displayed at the top of the column for that percentage.

Note that this percentaging capability is not available in command-line mode.


The program runs in three modes.


Keywords for Batch File Execution

The name of the batch file is given after '-b' on the command line. It contains the specifications for the listing. These specifications are given in the form "keyword = something" with one keyword per line. Keywords may be given in any order, either in upper or in lower case. The valid keywords are as follows (with significant characters shown in capital letters):

Keyword       Possible Specification          Default (if no keyword)

STUdy=        path of dataset directory       Look for variables only in
                                                current directory

VARiables=    variable name(s)                REQUIRED
               (separated by spaces/commas)
               can specify percents, as well
               as individual variables

Filter=       name(s) and codes of filter     No filter

GVARCase=     LOWER or UPPER                  No force to lower/upper case

SAvefile=     filename to receive output      Output (HTML) sent to screen
                (overwrite existing file)       (the standard output)

VALues=       (how to display numeric vars)
               Codes - numeric codes          Both
               Labels - category labels
                (if any; otherwise codes)
               Both - Codes AND labels

MAXCases=     max number of cases to display  500

STATistics=   mean, sum, min, max             No summary statistics

COLOR=        Yes                             No color for heading

LAnguagefile= Name of file with non-English   English labels on
                labels and messages             output

RUNtitle=     Title or comment for this run   No title or comment
                of the program

TExt=         Yes                             No text for variables


Keywords can be abbreviated down to the number of characters required to differentiate them from other keywords. Usually only a few characters are required. The keyword for the list of variables, for instance, can be given as "variables=" or "vars=". Either upper or lower case may be used.

Repetition of Keywords

If there is not enough room on a line to list all of the desired variables, the keyword can be repeated on a new line, and more variables can be listed. In such a case the second list is appended to the first list, for purposes of generating tables. This appending feature only applies to the keywords for specifying the variables to be listed and the filter variables. If other keywords are repeated, the program will print an error message and stop.


Anything on a line beginning with "#" is ignored by the batch processor and can therefore be used for comments. Blank lines are also ignored.

Examples of Batch Files

# Basic example

     vars = spend spend2 spend3
     filter = age(18-20) gender(1)

     savefile = mylist.htm


# Specify that only category labels be output
# (If a category has no label, the numeric
#  code value will be output.)
# Also restrict the output to a specified age and gender group.

     vars = spend spend2 spend3
     filter = age(18-20) gender(1)

     values = labels

     savefile = mylist.htm


# Get percentages as well as individual variables
# For example, the percent of total income
#  represented by wages

     vars = wages, totincom, $p(wages,totincom)

     filter = age(18-20) gender(1)
     savefile = mylist.htm


# Specify the location of the SDA study dataset.
# Also specify a run title and request the output of question text
#    for the specified variables.

     study = /sa/sdatest
     vars = spend spend2 spend3 spend4
     filters= age(18-50) party(1-3)

     runtitle = List the values of the spending variables
     text = yes

     savefile= mylist.htm


Option Flags for Command-Line Execution

The LISTCASE program is executed in command-line mode whenever option flags other than `-b' are used. The meaning of the available options is as follows:

List only the CASEID values.

-f filter(s)
Filter specifications to limit the cases to be displayed.
An example of a filter specification is: -f "age(18-25),gender(2)"
Note that double quotes are ALWAYS necessary around the filter specifications. (On Linux, single quotes might also work, but double quotes are definitely required for Windows.)

-v varlist
List of variables for which the code values will be displayed. Names of variables can be separated by commas or blanks. If they are separated by blanks, the whole list of variables needs to be put in double quotes.

A variable name may be given with a range restriction like "age(18-20)". This has the same effect as a filter specification. If a range restriction is used, that variable specification must be put in double quotes (unless the whole list of variables is already in quotes).

If you want to display a CASEID variable, you must specify that variable name in the list of requested variables. That variable is no longer displayed automatically by LISTCASE.

-s path
Look for variables in the specified study path(s) in addition to the current directory.

Show the category label, in addition to the category value, for each case listed.
(This option flag is a lower-case 'L'.)

Display (only) a list of options. The list of options is also displayed if no option flags at all are included on the command line.


listcase -v CASEID -f "age(18-25)"
List CASEID values for cases with the values 18-25 on age.

listcase -v age,educ,gender -f "region(1)"
List values of age, educ, and gender for cases in region 1.

listcase -l -v "income(1-5)"
List category values and labels on the income variable for everyone with response categories 1-5 on that variable.

listcase -l -v "income(1-5)" | more
Same as previous example, but display output one page at a time

listcase -l -v "income(1-5)" > mylisting.txt
Same as previous example, but redirect output to a file (instead of to the user's screen).

CSM, UC Berkeley/ISA
September 17, 2019