BookmarkSubscribeRSS Feed
pequignot
Calcite | Level 5

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.

4 REPLIES 4
Doc_Duke
Rhodochrosite | Level 12

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

markjc
Fluorite | Level 6

'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;

RW9
Diamond | Level 26 RW9
Diamond | Level 26

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

ballardw
Super User

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

sas-innovate-2024.png

Don't miss out on SAS Innovate - Register now for the FREE Livestream!

Can't make it to Vegas? No problem! Watch our general sessions LIVE or on-demand starting April 17th. Hear from SAS execs, best-selling author Adam Grant, Hot Ones host Sean Evans, top tech journalist Kara Swisher, AI expert Cassie Kozyrkov, and the mind-blowing dance crew iLuminate! Plus, get access to over 20 breakout sessions.

 

Register now!

What is Bayesian Analysis?

Learn the difference between classical and Bayesian statistical approaches and see a few PROC examples to perform Bayesian analysis in this video.

Find more tutorials on the SAS Users YouTube channel.

Click image to register for webinarClick image to register for webinar

Classroom Training Available!

Select SAS Training centers are offering in-person courses. View upcoming courses for:

View all other training opportunities.

Discussion stats
  • 4 replies
  • 5857 views
  • 0 likes
  • 5 in conversation