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.

SAS Innovate 2025: Call for Content

Are you ready for the spotlight? We're accepting content ideas for SAS Innovate 2025 to be held May 6-9 in Orlando, FL. The call is open until September 25. Read more here about why you should contribute and what is in it for you!

Submit your idea!

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