SAS : Reverse Order of Data

Live Online Training : SAS Programming with 50+ Case Studies

- Explain Programming Concepts in Simple English
- Live Projects
- Scenario Based Questions
- Job Placement Assistance
- Get 10% off till Oct 26, 2017
- Batch starts from October 28, 2017

This tutorial explains how to reverse order of data in SAS.
Reverse order of data

Create Sample Data
data temp;
input var1 @@;
2 9 6 4 3 8

Method I : With Sorting
data temp2;
set temp;
i = _N_;
proc sort data = temp2;
by descending i;
Method II : Without Sorting
data temp2;
do i = nobs to 1 by -1;
set temp nobs = nobs point=i;

  1. The POINT= option allows us to point to and select a given observation. 
  2. The NOBS= creates and names a temporary variable whose value is usually the total number of observations in the input data set or data sets. If more than one data set is listed in the SET statement, NOBS= the total number of observations in the data sets that are listed.

SAS Tutorials : 100 Free SAS Tutorials

About Author:

Deepanshu founded ListenData with a simple objective - Make analytics easy to understand and follow. He has close to 7 years of experience in data science and predictive modeling. During his tenure, he has worked with global clients in various domains like retail and commercial banking, Telecom, HR and Automotive.

While I love having friends who agree, I only learn from those who don't.

Let's Get Connected: Email | LinkedIn

Get Free Email Updates :
*Please confirm your email address by clicking on the link sent to your Email*

Related Posts:

1 Response to "SAS : Reverse Order of Data"

Next → ← Prev