Help using Base SAS procedures

Proc Export: arranging output.

Reply
N/A
Posts: 1

Proc Export: arranging output.

How do I arrange/control columns when I use proc export? 

I'm thinking of something like a "var" statement in proc print. 

EG:  I have a vbl called AGE, and another called AgeGrouped;  when using export Age goes to Col B and AgeGrouped goes to Col F.  I want to have them together to give to client, for his use..

Similar/related question:  is there a way to arrange columns in a SAS dataset?  If I could arrange things there then proc export might do what i want.

Trusted Advisor
Posts: 2,115

Re: Proc Export: arranging output.

Posted in reply to pequignot

Ordering the variables in a SAS data set requires understanding the Program Data Vector.  Read this chapter and see if that solves your problem:

SAS(R) 9.2 Language Reference: Concepts, Second Edition

Occasional Contributor
Posts: 5

Re: Proc Export: arranging output.

Posted in reply to pequignot

'Retain' will change the column order. The Proc Export column order from the origional dataset is: name | Emp_Id | dept

After altering the datset using Retain, The Proc Export column order is: name | dept | Emp_Id   

http://www.sascommunity.org/wiki/Re-ordering_variables

data people;

input name $ Emp_Id dept $;

datalines;

Timothy 225 Finance

Mark 301 Risk

Matt 249 IT

;

run;

  * Change column order ;

Data people ;

Retain name dept Emp_Id;

Set people;

Run;

Super User
Super User
Posts: 7,955

Re: Proc Export: arranging output.

Posted in reply to pequignot

Alternaitvely, don't use proc export as you are basically letting some code guess what you want as output.  There are other options out there:

- tagsets.excelxp + proc report - good for most uses.

- datastep to csv - Excel can read an interpret, flat text file so portable, virtually everything can read it.

- XML - your own particular XML creation, from datastep

Super User
Posts: 11,343

Re: Proc Export: arranging output.

Posted in reply to pequignot

And what's wrong with Proc print using NOOBS option?

Ask a Question
Discussion stats
  • 4 replies
  • 2317 views
  • 0 likes
  • 5 in conversation