statable Statistics for study and research

How do I set up a table so that I can calculate with it? (data matrix, codes, wide and long)

In brief

One row per observation (usually per person), one column per variable, one value per cell. Codes get labels, missing values stay empty or get a missing-value code, never 0. Whether the table is wide or long depends on the procedure.

Rows and columns

Codes and labels

Categories are coded as numbers (1 = female, 2 = male, 3 = diverse). The value label says what each code means so that tables and charts are readable; calculations use the code. A codebook records what every column and every code means.

Missing values

If someone skips a question, the cell stays empty, or a code of its own such as 99 applies, marked as "missing". A 0 would be counted as a measured value and distort the mean. Calculations then count only the rows with a value.

Wide or long?

Example: 12 people with 3 time points have in the wide form 12 rows and 4 columns (ID and three values), in the long form 36 rows and 3 columns (ID, time point, value). If three values are missing, the long form keeps 36 rows, 33 of them with a value.

How it works in Statable

  1. Under "Learning" open the unit: "Work it out yourself", then "Example" with the example "Does the reading training help?".
  2. On the page "Data" "Reshape" turns wide into long and back; the preview shows before and after. The number of rows of the long form can be compared with the calculation (96 children times 3 tests).

What is often misunderstood

For specialists

The long form corresponds to the "tidy" format: one row per observation, one column per variable. The number of rows of the long form is people times measurement points, with an incomplete design the number of measurements present.

Sources

For data setup and formats there is no source of its own in the collection; the text rests on common practice and on the help on reshaping.

Take away

  • One row per observation, one column per variable.
  • Codes need value labels and a codebook.
  • Missing values are marked, never filled with 0.
  • The long form has people times points in time rows, fewer if there are gaps.

Related

Open in Statable