BookmarkSubscribeRSS Feed
Pavan_SAS
SAS Employee
Hi all,

Can any one tell me, how can i sort the dataset in datastep (without proc sort).

regards,
pavan.
4 REPLIES 4
LinusH
Tourmaline | Level 20
The most obvious solution (for me) is to store the data in a SPDE (or SPDS if thats an option at the libname, and do a SET BY (which will result in a implicit sort on the BY variables). I'm not sure if this can be done with other techniques, but why...?

Regards,
Linus
Data never sleeps
deleted_user
Not applicable
a call routine may help;
like documented for CALL SORTC at http://support.sas.com/documentation/cdl/en/lrdict/59540/HTML/default/a003106052.htm .

Good luck
PeterC
LinusH
Tourmaline | Level 20
I didn't know about this one, really neat. Still, I can't see how you can easily sort a whole table, at least if it has many rows and columns. The question is what you want to accomplish.

/Linus
Data never sleeps
deleted_user
Not applicable
I don't see the point either.

Perhaps original poster expects to start an independant SAS session to sort the data and provide a signal when that is completed and the data available. However, I see no way for a data step compiler to tolerate the scenario. (or should a set of scl-type functions keep trying to open the data, then extract items of data without the normal use of the names of the variables in the sorted table 😉

The CALL SORTx() routines provide limited functionality(1 vector at a time), but that reflects the limited definition of the original poster's enquiry.
Of course, the multiple columns of information could be "ordered" if the data set to be sorted could be loaded into a hash table, keyed by the required sort by-variables. Again, that is not the explicitly requested solution.

I don't see how it helps to be able to sort a "sas data set" after the data step has started, that is an unknown requirement before the data step has started, and that must be completed before the data step has finished! But then, I didn't ask the question.
I await with interest for some explanation of the purpose of this requirement.

PeterC

sas-innovate-2024.png

Join us for SAS Innovate April 16-19 at the Aria in Las Vegas. Bring the team and save big with our group pricing for a limited time only.

Pre-conference courses and tutorials are filling up fast and are always a sellout. Register today to reserve your seat.

 

Register now!

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.

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
  • 4 replies
  • 736 views
  • 0 likes
  • 3 in conversation