BookmarkSubscribeRSS Feed

Sorting Through the Features of Proc Sort

Started ‎07-06-2018 by
Modified ‎07-06-2018 by
Views 7,880

Did you miss the Ask the Expert session on Sorting Through the Features in Proc Sort?  Not to worry, you can catch it On-Demand at your leisure.

 

Watch the webinar 

 

Remember Proc sort data=< Library.Dataset>;
By var;
Run; ??

 

Well, the PROC SORT of today tackles data challenges like never before. It goes past EBCDIC and ASCII to include additional international languages beyond English.

 

Imagine having the ability to sort allowing for case insensitivity of names such as McGowan or the ability to sort addresses by the address number and the address name with the same field or eliminating records with unique keys vs. duplicates.

 

In this session we will explore some of the exciting PROC SORT tools and goodies.

 

We look at:

  • Proc Sort Basics
  • Modern Day Sort Functionality
  • Linguistic Collating options

TUTS-Sorting-Photos-preview.jpg

 

I have added the Q&A from the session below and attached you will find the slides:


Q. If I use a WHERE with PROC SORT, do I have to use OUT=

 

A: The danger of NOT using an OUT= is that you could overwrite the original data. For example, if you used a “WHERE age ge 14” when sorting SASHELP.CLASS with an OUT=, then you would be creating a subset of ages 14, 15 and 16. But, if you did NOT have an OUT= and you had write access to the data file, then you would essentially be overwriting the original data with that subset. We’ll post an example of the code (using a WORK dataset) in the Q&A log.

 

 

Sort log.jpg  

Q: I am told that I need to use something called SYNCSORT. Is that a SAS Product? How do I use it:

A: No, SYNCSORT is a “host” sort routine and is frequently used on IBM mainframe computers. There are three SAS system options that work together to let you use a host sort. Remember, the SYNCSORT product itself needs to be installed, and then SAS needs to be told how to find and use it. The values for these options are operating system specific.

We’ll put an example of the code in the Q&A log.

Option Description

SORTPGM= Specifies whether SAS sorts using the SAS sort utility or the host sort utility.

SORTCUTP= Specifies the number of bytes up to which SAS sorts. If the number of bytes in the data set is greater than the specified number, the host sort program sorts the entire data set.

SORTNAME= Specifies the name of the host sort utility.

 

Here’s an example:

options sortpgm=host

        sortcutp=1M

        sortname=syncsort;

proc sort data=detail;

  by ID;

run;

 

Consult the Operating System Companion for your platform to see the specifics on using host sorts in your environment.   

 

Q: Can I create an index on my dataset using PROC SORT? What happens if I try to sort an indexed data set?

A: Yes, you can. PROC SORT allows you to use the INDEX= option for the OUT= dataset. We’ll put an example in the Q&A log:

proc sort data=old

                out=new(index=id);

  by id;

run;

 

Want more tips? Be sure to subscribe to the Ask the Expert board to receive follow up Q/A, slides and recordings from other SAS Ask the Expert webinars.

Version history
Last update:
‎07-06-2018 12:29 PM
Updated by:

sas-innovate-2024.png

Don't miss out on SAS Innovate - Register now for the FREE Livestream!

Can't make it to Vegas? No problem! Watch our general sessions LIVE or on-demand starting April 17th. Hear from SAS execs, best-selling author Adam Grant, Hot Ones host Sean Evans, top tech journalist Kara Swisher, AI expert Cassie Kozyrkov, and the mind-blowing dance crew iLuminate! Plus, get access to over 20 breakout sessions.

 

Register now!

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.

Article Labels
Article Tags