Assign serial numbers to observations in a data set in SAS

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:

DATA market_new;
SET mydata_old;
  id = _N_;  
RUN;

Here, id = _N_; copies observation numbers to the variable id.

If you have questions about using statistical and mathematical software at Indiana University, contact the UITS Research Applications and Deep Learning team.

This is document adxp in the Knowledge Base.
Last modified on 2023-10-02 13:38:23.