BookmarkSubscribeRSS Feed
aamoen
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;

run;

 

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

 

Thanks!

 

2 REPLIES 2
ballardw
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.

Patrick
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)

 

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!

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
  • 277 views
  • 0 likes
  • 3 in conversation