list
Prints the actual rows to the screen.
What we have
- any variable list, with
ifandin
Coming later
- the display options:
noobsis accepted but changes nothing set mincelldoes not reachlist, so it can still show one person's row
You may shorten it to l.
How you write it
list [varlist] [if] [in]
Square brackets mean optional. A vertical bar means choose one.
What it does
The plainest possible look at the data. Name the columns you care about and Virata prints them; say nothing and it prints them all.
Almost always you want in 1/10 on the end, which means "rows 1 to 10". Without it a 6,000-row dataset scrolls past for a long time.
Try it
Every example below was run after sysuse vira.sample02, clear.
. list state mpce in 1/5
state mpce
--------------------
1. Rajasthan 2526.16
2. Odisha 3250.25
3. Kerala 3247.12
4. Odisha 2346.14
5. Rajasthan 2978
The same thing in pandas and in R
pandas
import numpy as np mask = (np.arange(1, len(df) + 1) >= 1) & (np.arange(1, len(df) + 1) <= 5) df[['state', 'mpce']].head()
R
library(dplyr)
df %>% filter(row_number() >= 1 & row_number() <= 5) %>% select(state,
mpce) %>% head(10)
# This R has NOT been run against a real R yet: read it as documentation.