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.

Ready to join fellow brilliant minds for the SAS Hackathon?

Build your skills. Make connections. Enjoy creative freedom. Maybe change the world. Registration is now open through August 30th. Visit the SAS Hackathon homepage.

Register today!
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
  • 576 views
  • 0 likes
  • 4 in conversation