Turn on suggestions

Auto-suggest helps you quickly narrow down your search results by suggesting possible matches as you type.

Showing results for

- Home
- /
- Programming
- /
- SAS Procedures
- /
- Help converting ROW_NUMBER() OVER (PARTITION BY

Options

- RSS Feed
- Mark Topic as New
- Mark Topic as Read
- Float this Topic for Current User
- Bookmark
- Subscribe
- Mute
- Printer Friendly Page

🔒 This topic is **solved** and **locked**.
Need further help from the community? Please
sign in and ask a **new** question.

- Mark as New
- Bookmark
- Subscribe
- Mute
- RSS Feed
- Permalink
- Report Inappropriate Content

Posted 12-04-2017 12:23 PM
(31497 views)

Could someone please help me to understand how I could convert the following into PROC SORT then PROC RANK?

ROW_NUMBER() OVER (PARTITION BY UNIQUE_ID ORDER BY mem_no desc, drug_id desc, RX_FILL_DT ASC) AS RANK

FYI, formats:

alphanumeric:

UNIQUE_ID

DRUG_ID

date:

RX_FILL_DT

numeric:

MEM_NO

SAS EG v. 7.13

1 ACCEPTED SOLUTION

Accepted Solutions

- Mark as New
- Bookmark
- Subscribe
- Mute
- RSS Feed
- Permalink
- Report Inappropriate Content

`if first.rx_fill_dt_asc ...`

I think auto correct deleted the period, there should be a period between.

FIRST. identifies the first in that particular variable group.

5 REPLIES 5

- Mark as New
- Bookmark
- Subscribe
- Mute
- RSS Feed
- Permalink
- Report Inappropriate Content

PROC SORT data=have;

by mem_no desc descending drug_id RX_FILL_DT ASC;

run;

proc rank data=have;

by < ... >;

VAR ...;

run;

I'm not sure what variable is being ranked here or if it's just creating a count variable per group. I suspect the latter which would be easier in a data step.

```
data want;
set have;
by < >;
if first rx_fill_dt_asc then count=0;
count+1;
run;
```

- Mark as New
- Bookmark
- Subscribe
- Mute
- RSS Feed
- Permalink
- Report Inappropriate Content

I get this error:

if first rx_fill_dt_asc then count=0;

______________

388

76

ERROR 388-185: Expecting an arithmetic operator.

if first rx_fill_dt_asc then count=0;

______________

388

76

ERROR 388-185: Expecting an arithmetic operator.

- Mark as New
- Bookmark
- Subscribe
- Mute
- RSS Feed
- Permalink
- Report Inappropriate Content

`if first.rx_fill_dt_asc ...`

I think auto correct deleted the period, there should be a period between.

FIRST. identifies the first in that particular variable group.

- Mark as New
- Bookmark
- Subscribe
- Mute
- RSS Feed
- Permalink
- Report Inappropriate Content

Good afternoon!

Have you solved the case? I have the same arithmetic overflow problem.

- Mark as New
- Bookmark
- Subscribe
- Mute
- RSS Feed
- Permalink
- Report Inappropriate Content

@OsiasEduardo wrote:

Good afternoon!

Have you solved the case? I have the same arithmetic overflow problem.

This post has nothing to do with arithmetic overflow. Please post your question as a new post.

Registration is open! SAS is returning to Vegas for an AI and analytics experience like no other! Whether you're an executive, manager, end user or SAS partner, SAS Innovate is designed for everyone on your team. Register for just $495 by 12/31/2023.

**If you are interested in speaking, there is still time to submit a session idea. More details are posted on the website. **

What is Bayesian Analysis?

Learn the difference between classical and Bayesian statistical approaches and see a few PROC examples to perform Bayesian analysis in this video.

Find more tutorials on the SAS Users YouTube channel.