BookmarkSubscribeRSS Feed
serrld113
Obsidian | Level 7

Is there a setting in SAS enterprise guide (6.1) , that will make it so my data set is automatically sorted ascending or descending? (beyond using proc sort or an order by)

 

Thank you!

 

5 REPLIES 5
SuryaKiran
Meteorite | Level 14

Hello,

 

As far as I'm aware, there is not such option in SAS EG 6.1. Apart from proc sort & order by, point & click feature ( which is order by behind ) can be used to sort the data in SAS EG.

 

Having automatic sort for the datasets that are added to the process flow might cause issues when a very large table is added, which is why I think that option is not available. 

Thanks,
Suryakiran
TomKari
Onyx | Level 15

I'm not aware of one, and given that SAS is frequently used to deal with very large datasets, an option like that would seem to be counterproductive. I can't see a use case for it, but I've been surprised in the past! Why are you asking about this? Maybe there's another way to tackle your problem.

 

Tom

serrld113
Obsidian | Level 7

My coworker and I work with hundreds of thousands of records. Sometimes we have duplicates so we do a proc sort nodupkey to select what we need. 

 

It goes something like this:

 

proc sql;
create table mytable as 
select distinct var1, var2, var3, var4, var5
from have
order by var1, var2
;
quit;

proc sort nodupkey;
by var1 var2;
run;

Where we need a data set unique by var1 and var2. My SAS will ALWAYS pick up the first record as ordered by the order by in the proc sql (and it almost seems like SAS will always order the rest of my variables anyways....I haven't been able to replicate this to show you). Hers picks up the second or third record even though our programs look the same. So what ends up happening is that she has to order by all the variables we're using.

Here is the kicker: when our manager runs her program on his computer, he ends up picking up the same record as I do!!

So we were wondering if there is a default setting that SAS uses to order the data. 

SuryaKiran
Meteorite | Level 14

When you run the PROC SORT without OUT= option, the original dataset will be re-ordered. What I suspect is someone might be changing the order of the source datasets. 

Thanks,
Suryakiran
Patrick
Opal | Level 21

I'm with @SuryaKiran that if you overwrite the source data set with an ordered and deduped version then someone else might be using this already sorted data  - and that could explain different results.

 

Looking at the code you've posted and that you just want unique rows per var1, var2 I can't see any reason to use a SQL distinct of more variables first. That just adds additional processing. You should get consistent results with less passes through the data and less sorting by using below code:

proc sort nodupkey
  data=have
  out=have_sorted
  ;
  by var1 var2;
run;

sas-innovate-2024.png

Available on demand!

Missed SAS Innovate Las Vegas? Watch all the action for free! View the keynotes, general sessions and 22 breakouts on demand.

 

Register now!

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