Stata 11 help for numlist
help numlist
-------------------------------------------------------------------------------
Title
[U] 11.1.8 numlist -- Number lists
Remarks
See nlist for the numlist programming command.
A numlist is a list of numbers with blanks or commas in between. There
are a number of shorthand conventions to reduce the amount of typing
necessary. For instance:
2 just one number
1 2 3 three numbers
3 2 1 three numbers in reversed order
.5 1 1.5 three different numbers
1 3 -2.17 5.12 four numbers in jumbled order
1/3 three numbers: 1, 2, 3
3/1 the same three numbers in reverse order
5/8 four numbers: 5, 6, 7, 8
-8/-5 four numbers: -8, -7, -6, -5
-5/-8 four numbers: -5, -6, -7, -8
-1/2 four numbers: -1, 0, 1, 2
1 2 to 4 four numbers: 1, 2, 3, 4
4 3 to 1 four numbers: 4, 3, 2, 1
10 15 to 30 five numbers: 10, 15, 20, 25, 30
1 2:4 same as 1 2 to 4
4 3:1 same as 4 3 to 1
10 15:30 same as 10 15 to 30
1(1)3 three numbers: 1, 2, 3
1(2)9 five numbers: 1, 3, 5, 7, 9
1(2)10 the same five numbers: 1, 3, 5, 7, 9
9(-2)1 five numbers: 9, 7, 5, 3, and 1
-1(.5)2.5 the numbers: -1, -.5, 0, .5, 1, 1.5, 2, 2.5
1[1]3 same as 1(1)3
1[2]9 same as 1(2)9
1[2]10 same as 1(2)10
9[-2]1 same as 9(-2)1
-1[.5]2.5 same as -1(.5)2.5
1 2 3/5 8(2)12 eight numbers: 1, 2, 3, 4, 5, 8, 10, 12
1,2,3/5,8(2)12 the same eight numbers
1 2 3/5 8 10 to 12 the same eight numbers
1,2,3/5,8,10 to 12 the same eight numbers
1 2 3/5 8 10:12 the same eight numbers
Advice: Do not use commas to separate the entries -- use spaces instead
-- because commas are not always allowed. You may use commas when a
numlist appears inside the parentheses of an option, but you may not use
commas in other cases.
Examples
. sysuse uslifeexp
. line le_wm year, ylabel(0 20(10)80)
. sysuse auto
. centile price, centile(5 50 95)
. forvalues i = 10(-2)1 {
> display `i'
> }
Saved results
numlist saves the following in r():
Macros
r(numlist) the expanded numeric list
Also see
Manual: [U] 11.1.8 numlist
Help: [U] 11 Language syntax, [P] numlist, [P] syntax
|