Help using Base SAS procedures

Variable Re-order

Accepted Solution Solved
Reply
Super Contributor
Posts: 276
Accepted Solution

Variable Re-order

i want to print the variable names based on alphabetical order..

can you suggest any one????

thanks..


Accepted Solutions
Solution
‎01-21-2012 12:11 PM
PROC Star
Posts: 7,487

Variable Re-order

Posted in reply to kuridisanjeev

Here is one way:

proc sql noprint;

  select name

    into :reorder

      separated by ' '

        from dictionary.columns

          where libname="SASHELP" and

             memname="CLASS"

               order by name

  ;

quit;

proc print data=sashelp.class;

  var &reorder.;

run;

View solution in original post


All Replies
Solution
‎01-21-2012 12:11 PM
PROC Star
Posts: 7,487

Variable Re-order

Posted in reply to kuridisanjeev

Here is one way:

proc sql noprint;

  select name

    into :reorder

      separated by ' '

        from dictionary.columns

          where libname="SASHELP" and

             memname="CLASS"

               order by name

  ;

quit;

proc print data=sashelp.class;

  var &reorder.;

run;

Super Contributor
Posts: 276

Variable Re-order

Thank  you art297 for quick reply..

i found another way..

proc contents data=sashelp.class out=class1(keep=name);

run;

proc sql;

select name into:names separated by '' from class1;

quit;

data final;

retain &names;

set sashelp.class;

run;

PROC Star
Posts: 7,487

Variable Re-order

Posted in reply to kuridisanjeev

I'm sure there are additional ways.  I like the one I proposed as it requires less steps then the method you found.

🔒 This topic is solved and locked.

Need further help from the community? Please ask a new question.

Discussion stats
  • 3 replies
  • 153 views
  • 0 likes
  • 2 in conversation