Alternative to _N_ in PROC SQL

Deepanshu Bhalla 3 Comments , ,
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;
Related Posts
Spread the Word!
Share
About Author:
Deepanshu Bhalla

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

Post Comment 3 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
  3. Was really helpful!

    ReplyDelete
Next → ← Prev