01-08-2013 07:14 AM
How to sort the COLUMN headers which includes numeric,special characters and also space? I got some idea on column sorting but it applies only for proper SAS COLUMN NAMES which satisfies the rules. The above NUMERIC COLUMNS resulted after using PROC TRANSPOSE.
01-08-2013 09:03 AM
SAS seems to only put columns in the order that they are created, not numeric or alphabetical order. If you want to specify the order of the columns, I have used one of two ways:
1. Use PROC SQL and use the SELECT statement to list out the columns that you want in the order that you want.
2. Use a DATA step and use the LENGTH statement to specify lengths of the columns in the order that you want (more work and less efficient).
This, however, does not seem too enjoyable if you have a lot of columns. In that case, you could probably try something like:
proc sort data=sashelp.vcolumn (where=(libname='AAA' & memname='BBB')) out=sorted;
select name into :columns separated by ', '
where name not in ('',''); /* fill in the blank single quotes with the names of variables that you are not interested in sorting */
create table sortedColumns as
In the above code snippet, AAA is the library containing your transposed dataset, and BBB is the name of the transposed dataset. I just created a macro variable that stores the names of the variables that you want to sort (separated by a comma for use in PROC SQL). Then I created a new table that keeps those columns in that sorted order.
I hope this helps!
01-08-2013 09:05 AM
I just noticed that you tagged this post for help in SAS Enterprise Guide. I have never used EG, so I don't know that what I just told you will be of much help. Hopefully the idea can somehow be incorporated, though.
01-08-2013 09:48 AM