BookmarkSubscribeRSS Feed
Obsidian | Level 7

How would i write the following %sort statement using proc sort?


%sort(data.rade,camp_cd appl_id RADE_RELSHIP_TYP RADE_ACCT_NO,option=nodupkey)


I believe it would be:


proc sort data=data.rade nodupkey;

      by camp_cd appl_id RADE_RELSHIP_TYP RADE_ACCT_NO;



Is this correct/will give me the same results?  Also, can %sort be used outside of a macro?




Super User

%sort would, in SAS, refer to macro code or "is a macro".  So "outside of a macro" is pretty meaningless but would be usable. The code could do anything. If you cannot provide the source code of %sort we really can't answer this completely. I don't recognize this is a standard SAS supplied macro so would not even bother to guess.


IF this is SAS code set options MPRINT before executing it. That will show the statements generated by the macro in the log:

options mprint;

%sort(data.rade,camp_cd appl_id RADE_RELSHIP_TYP RADE_ACCT_NO,option=nodupkey)

options nomprint; /* turn off the option*/

If you have questions about the content of the log then copy ALL the text from the log, open a text box on the forum using the </> icon above the message window and pasting the text.

The text, you can see on above, is important to preserve line formatting as the main message window on this forum is known to reformat pasted text and may move stuff making it harder to understand, especially warnings and error messages.



If %sort is supposed to be from another programming language then you need to tell us what it is supposed to do.

Opal | Level 21

This looks like a macro call to a site specific custom macro and though we can't know what this macro does. 

If you use below two options then you'll get in the SAS log what SAS code the macro generates as well as where the macro definition is stored in your environment. That should answer your question - else please share the log created when running below and eventually also the macro definition (the code from the .sas file from the location where the log tells you it found the macro definition).

options mprint mautolocdisplay;
%sort(data.rade,camp_cd appl_id RADE_RELSHIP_TYP RADE_ACCT_NO,option=nodupkey)




Registration is open! SAS is returning to Vegas for an AI and analytics experience like no other! Whether you're an executive, manager, end user or SAS partner, SAS Innovate is designed for everyone on your team. Register for just $495 by 12/31/2023.

If you are interested in speaking, there is still time to submit a session idea. More details are posted on the website. 

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.

Get the $99 certification deal.jpg



Back in the Classroom!

Select SAS Training centers are offering in-person courses. View upcoming courses for:

View all other training opportunities.

Discussion stats
  • 2 replies
  • 3 in conversation