Alternative to _N_ in PROC SQL

In PROC SQL, we can use MONOTONIC() function to generate row numbers. It is an alternative to _N_ in data step.

SAS Code : To select row numbers between 10 and 20
proc sql noprint;
create table temp as
select  *
from sashelp.class
where monotonic() between 10 and 20;
quit;
SAS Code : To generate row numbers
proc sql noprint;
create table class2 as
select  monotonic() as Number, *
from sashelp.class;
quit;

Proc SQL Tutorials : 15 Proc SQL Tutorials


SAS Tutorials : 100 Free SAS Tutorials

About Author:

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

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:
2 Responses to "Alternative to _N_ in PROC SQL"
  1. Very helpful explanation n easily understandable....thnx fr d teaching

    ReplyDelete
  2. Very helpful explanation n easily understandable....thnx fr d teaching

    ReplyDelete

Next → ← Prev