BookmarkSubscribeRSS Feed
lyna123
Calcite | Level 5

Hi, 

 

I have a table with 45 stores and their total sales. I need to find the stores with the 3 worst sales. 

I know I can sort the values ascending and then deduct the last 3 but I wonder if there is a way to find the last 3 directly. when I use de min, its only for one value, how do we do to find the 3 min?

 

Thank you, 

Lyna

3 REPLIES 3
novinosrin
Tourmaline | Level 20

How about proc rank?

 

You could filter the ranked variable to your needs. 

ballardw
Super User

Any particular reason why Proc SQL must be used? Almost anything that involves order is more difficult in SQL. Did you mean to say sort ASCENDING and keep the first three results (obs=3)?

 

Proc Means can do this depending on how many other variables need to be in the output in a single step.

SAS Innovate 2025: Call for Content

Are you ready for the spotlight? We're accepting content ideas for SAS Innovate 2025 to be held May 6-9 in Orlando, FL. The call is open until September 16. Read more here about why you should contribute and what is in it for you!

Submit your idea!

SAS Enterprise Guide vs. SAS Studio

What’s the difference between SAS Enterprise Guide and SAS Studio? How are they similar? Just ask SAS’ Danny Modlin.

Find more tutorials on the SAS Users YouTube channel.

Click image to register for webinarClick image to register for webinar

Classroom Training Available!

Select SAS Training centers are offering in-person courses. View upcoming courses for:

View all other training opportunities.

Discussion stats
  • 3 replies
  • 635 views
  • 0 likes
  • 4 in conversation