Help using Base SAS procedures

label order in output

Reply
N/A
Posts: 1

label order in output

Hi, hope you can help:

Trying to find out if it’s possible to reorder the output labels from sas E.g. the output I get out at the mo would be (these are just examples, not real variables etc):



.....AF GH SV DK

GH xx xx xx xx

DK xx xx xx xx

SV xx xx xx xx

AF xx xx xx xx



But I need:



....GH DK SV AF

DK xx xx xx xx

SV xx xx xx xx

GH xx xx xx xx

AF xx xx xx xx



Because that’s how it’s presented in our publications. It’s not a big deal, but just means I spend time faffing moving columns around in excel when I sure it could just output it like this straight away. The labels are ones I have defined in proc formats.

would be a massive help if it is possible but not a huge problem if it isn't.

Thanks in advance
SAS Super FREQ
Posts: 8,743

Re: label order in output

Hi:
Are you using PROC EXPORT to get the data into Excel??? Or are you using ODS to send a report to Excel??? If you are using ODS, then what is your procedure of choice (PROC PRINT, PROC REPORT or PROC TABULATE???).

Actually, seeing the "real" data and variables would be of more help than seeing fake data...for example, you have the same 'values' going down the rows as you have for the column headers. How are you getting or generating this data??? Knowing a bit more would be helpful.

cynthia.
Valued Guide
Posts: 2,175

Re: label order in output

tinc

there are many ways to re-order columns
possibly there are more ways than programmers
here is a simple 1
data reordered ;
retain GH DK SV AF ;
set original ;
run;
If you don't need or want to avoid the second copy of the information, make the first line
data reordered /view= reordered ;
Then reordered is a view which when referred will return the columns in your GH DK SV AF order.
But before going away with this answer, please respond to Cynthia's questions - her responses may just be far more illuminating.

peterC
Super User
Posts: 9,681

Re: label order in output

Hi.
Are you to try to use ' notsorted' option in proc format for customizing order of value.


[pre]

proc format;
value fmt(notsorted)
1,2 = 'GH'
3,4 ='DK'
5,6='SV'
7,8='AF'
;
value _fmt(notsorted)
1,2 = 'DK'
3,4 ='SV'
5,6='GH'
7,8='AF'
;

data temp;
input a b;
format a _fmt.;
format b fmt.;
cards;
1 5
2 8
3 6
2 1
8 3
7 2
6 4
;
run;

proc tabulate data=temp;
class a b;
table a,b;
run;
[/pre]



Ksharp
Ask a Question
Discussion stats
  • 3 replies
  • 109 views
  • 0 likes
  • 4 in conversation