Friday, April 7, 2017

Re-Ordering SAS Columns (SAS)

Often, after numerous joins and re-formattings, you will find that your SAS data sets have become disorganized, and by this, I mean that the column order of the data set exists in a way that is difficult to fully summarize. To fix this problem, to re-order the columns that exist within your data set, utilize the following code:

Data SETB;
         Retain X Y Z W;
Set SETA;
Run;


SETB being the name of the new set that will contain the re-ordered variables, SETA being the set that requires the variables to be re-ordered.

Unlisted variables that existed in the prior set will still remain in the new set, even if not listed within the RETAIN statement, however, they will be listed at the very end of the set.

SAS Retain Statement: SAS University

No comments:

Post a Comment

Note: Only a member of this blog may post a comment.