If you are given an unsorted data set, how will you read the last observation to a new dataset?

We can read the last observation to a new dataset using end = dataset option.

For example:

  1. data example.newdataset;
  2. set example.olddataset end=last;
  3. If last;
  4. run;
    Where newdataset is a new data set to be created and olddataset is the existing data set. last is the temporary variable (initialized to 0) which is set to 1 when the set statement reads the last observation.