Monday, October 30, 2006

The Monotonic Function

There is an undocumented function that enables you to generate observation numbers with a PROC SQL statement and retain them in an output data set.

You can use the NUMBER option in a PROC SQL statement to print observation numbers, but the observation numbers are not retained (just like PROC PRINT w/o the nobs option).

To keep the observation numbers in the output table, use the MONOTONIC function in the SELECT statement.

Example:

Proc sql;
create table step1 as
select monotonic() as ID,
district, district_name
from perm.districts;
quit;

To do the same thing in a data step:
ID = _n_;

14 Comments:

At 2:02 PM, Anonymous Anonymous said...

The Monotonic Function is undocumented for SAS's version of SQL for a reason it can cause some unexpected results. This is documented by SAS.

 
At 5:15 AM, Anonymous Anonymous said...

So...what are the unexpected results? If you can elaborate please because I can't find anything on this @ SAS. This is the next best thing in proc sql if you do not want to do a data step.

 
At 9:57 PM, Blogger Easy said...

I've found the results to not be in order - monotonic() = 1 appears on the 5th observation.

 
At 12:26 AM, Anonymous Anonymous said...

How to apply monotonic to each group in a table??

example:

Student Subjects Count
ABC P 1
ABC Q 2
ABC R 3
ABC S 4
PQR T 1
PQR Y 2
PQR R 3
PQR Q 4

 
At 2:13 AM, Blogger Unknown said...

It's really interesting articles, more people are would do it those type of information.,,I like that kind of valuable post.
ccna training

 
At 1:59 AM, Blogger Priscilla said...

Thank you for taking the time to provide us with your valuable information. We strive to provide our candidates with excellent care.As always, we appreciate your confidence and trust in us..SAP Training in chennai

 
At 2:13 AM, Anonymous keerthi said...


Great post!! This can be one particular of the most useful blogs We’ve ever arrive across on this subject. Basically Wonderful. I am also a specialist in this topic so I can understand your hard work.

Corporate Training in Chennai

 
At 12:11 AM, Blogger Unknown said...

This blog is having a wonderful talk. The technology are discussed and provide a great knowledge toall. This helps to learn more details about technology. All this details are important for this technology. Thank you for this blog.
Digital Marketing Company

 
At 2:08 AM, Blogger Unknown said...

Your thinking toward the respective issue is awesome also the idea behind the blog is very interesting which would bring a new evolution in respective field. Thanks for sharing.

Best Dental Clinic In Vellore

 
At 9:49 PM, Blogger sathya said...

I read this content really awesome.You provided another one great article.I hope this information may change my business carrier.I can remember these things whenever taking the decision.

MSBI Training in Chennai

Informatica Training in Chennai

 
At 2:51 AM, Anonymous Mahalyasree said...

It’s the best time to make some plans for the future and it is time to be happy. I’ve read this post and if I could I want to suggest you few interesting things or suggestions.You can write next articles referring to this article. I desire to read even more things about it..
Best Interior Designers in Chennai
Interior Designers in Chennai

 
At 1:10 AM, Anonymous Anonymous said...


Thank you for this great article which is about Monotonic Functions .keep more updates.
SEO Company in India

 
At 3:55 AM, Blogger Unknown said...


very very amazing explaintion....many things gather about yourself...yes realy i enjoy it

Interesting blog post.This blog shows that you have a great future as a content writer.waiting for more updates...
Digital Marketing Company in India

Digital Marketing Services in India

Digital Marketing Agency in India

 
At 1:14 AM, Blogger Bollywood Hungama said...

Bollywood News in Hindi - Check out the latest Bollywood news, new Hindi movie reviews, box office collection updates
Infinite Full Movie Download & Review
Friends The Reunion Full Episode Download & Review

 

Post a Comment

<< Home