BookmarkSubscribeRSS Feed
max_ros
Obsidian | Level 7

Goood aftenoon at all,

i need to translate MS-SQL code in proc rank sas code. It is possible?

If yes, how? in particular i'm intersted in "translate" "RANK () OVER .." . IN SAS CODE "PROC RANK"

This is MS-SQL code :

 

tmp_ as (

                    select

                           accntnum,

                           policytype,

                           userdef1,

                           usertxt2,

                           RANK() OVER ( PARTITION BY accntnum, usertxt2 order by RT_RANK ) as RN

                    from

                           tmp

 

Thanks a lot in  advance.

massimo

3 REPLIES 3
ballardw
Super User

Please provide an example of the input data and what the result would be.

Not everyone here knows MS-SQL and perhaps that do have some acquaintance do no use those features. However we can often provide an example of pounding data into the desired form.

 

And a solution may not require proc rank.

max_ros
Obsidian | Level 7
Thanks for the suggestion. I have however arrived at a solution without using the proc rank but instructions like "first" "last" (ordering the dataset for the variables of interest).
thanks a lot
ballardw
Super User

@max_ros wrote:
Thanks for the suggestion. I have however arrived at a solution without using the proc rank but instructions like "first" "last" (ordering the dataset for the variables of interest).
thanks a lot

Please post your solution code and mark that as the accepted solution so that others searching this forum have an example of a solution if they have a similar problem/ question.

sas-innovate-2026-white.png



April 27 – 30 | Gaylord Texan | Grapevine, Texas

Registration is open

Walk in ready to learn. Walk out ready to deliver. This is the data and AI conference you can't afford to miss.
Register now and lock in 2025 pricing—just $495!

Register now

How to Concatenate Values

Learn how use the CAT functions in SAS to join values from multiple variables into a single value.

Find more tutorials on the SAS Users YouTube channel.

SAS Training: Just a Click Away

 Ready to level-up your skills? Choose your own adventure.

Browse our catalog!

Discussion stats
  • 3 replies
  • 1369 views
  • 0 likes
  • 2 in conversation