DATA Step, Macro, Functions and more

proc sort and select 10 largest values

Reply
Super Contributor
Posts: 318

proc sort and select 10 largest values

 

I want to select the top 10 obs with largest "amount" variable. Using the code belwo, sorting is done, but I still got the whole set, not the first 10 obs. What could be the problem that "obs=10" did not work?

 


proc sort data=have out=top_10 (obs=10);
by descending amount;
run;
Super User
Posts: 11,343

Re: proc sort and select 10 largest values

Posted in reply to fengyuwuzu

From the online documentation onthe OBS=Data set option:

Restriction: Use with input data sets only

 

Sort you data and then use

Data top_10;

   set top_10 (obs=10);

run;

Ask a Question
Discussion stats
  • 1 reply
  • 252 views
  • 0 likes
  • 2 in conversation