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;
About Author:

Deepanshu founded ListenData with a simple objective - Make analytics easy to understand and follow. He has over 8 years of experience in data science. During his tenure, he has worked with global clients in various domains like Banking, Insurance, Telecom and Human Resource.

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
Love this Post? Spread the Word!
Share