In SAS, how can I assign serial numbers to observations in a data set?
To assign serial numbers to observations in a data set in SAS, create a
variable using _N_, a system variable, which contains
observation numbers from 1 through n. Consider the following example:
The id = _N_; copies observation numbers to the variable
id.
For more about statistical and mathematical software, email the UITS Stat/Math Center, visit the center's web page, or phone 812-855-4724 (IUB) or 317-278-4740 (IUPUI). The center is located in Bloomington at 410 N. Park Avenue, and is open for consultation by appointment Monday-Friday 9am-5pm.
Last modified on March 15, 2011.







