BookmarkSubscribeRSS Feed
HeatherNewton
Quartz | Level 8
proc sort data=apple;
by colour weight;
run;

for proc sort, input data is dataset apple, is the output data set after sorting is also apple? 

5 REPLIES 5
BrahmanandaRao
Lapis Lazuli | Level 10
Proc sort data = apple out=sort_apple;
By variable;
run;
Amir
PROC Star

Hi,

 

In answer to your question, yes the sorted data set would also be called apple.

 

If you want to create a new sorted data set and leave the input data set unchanged then the solution posted by @BrahmanandaRao should be fine.

 

For more information on the proc sort syntax you can see the documentation.

 

 

Kind regards,

Amir.

ballardw
Super User

How about reading the documentation at https://documentation.sas.com/doc/en/pgmsascdc/9.4_3.4/proc/p0ha9ymifyaqldn14m2xlqw252wa.htm

which clearly states

 

In the following example, the original data set was in alphabetical order by last name. PROC SORT replaces the original data set with a data set that is sorted by employee identification number. The following log shows the results from running this PROC SORT step. Observations Sorted by the Values of One Variable shows the results of the PROC PRINT step. The statements that produce the output follow:

 
proc sort data=employee;
   by idnumber;
run;

proc print data=employee;
run;

You can provide another data set as an OUT= option, as @BrahmanandaRao shows, if you want to create a different data set which is highly recommended if you use any of the options that remove observations.

Kurt_Bremser
Super User

Maxim 2: Read the Log.

It will tell you the answer right there on the spot.

 

BIG hint: reading the log is always quicker than posting here. Only when you have trouble interpreting the log, come here for guidance.

HeatherNewton
Quartz | Level 8

thanks for your  hint, you are so right

hackathon24-white-horiz.png

The 2025 SAS Hackathon has begun!

It's finally time to hack! Remember to visit the SAS Hacker's Hub regularly for news and updates.

Latest Updates

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
  • 5 replies
  • 1192 views
  • 1 like
  • 5 in conversation