BookmarkSubscribeRSS Feed
kajal_30
Quartz | Level 8

Hi Channel,

 

I am trying to run the following code but not getting identical results

please advice 

 

This is what I have:


PROC SORT DATA = A OUT = B;
BY T;
QUIT;

 

This is what I want:

 

PROC SQL;
CREATE TABLE B AS SELECT *
FROM A
GROUP BY T
ORDER BY T
;
QUIT;

 

Thanks 

 

2 REPLIES 2
novinosrin
Tourmaline | Level 20

Can you post a sample data for folks to test plz

Astounding
PROC Star

PROC SQL does not guarantee the order of the observations as they are read in.  It can very well read observations from A in a different order than they appear within A.

 

PROC SORT does guarantee the incoming order is the same as the order in A.  However, there is a further complication depending on whether the option EQUALS (usually the default) or NOEQUALS is in effect.  

 

If the observations take on unique values for T, you will always get the same result.  If there might be multiple observations for the same value of T, you can get different results.  In both cases, the output will be sorted by T.  But within identical values of T, the order can be different.

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
  • 2 replies
  • 933 views
  • 2 likes
  • 3 in conversation