BookmarkSubscribeRSS Feed
AZ_KI
Calcite | Level 5

I have a table with 16 million rows and I would to add a column to the table which I did with :

proc sql;

     alter table A

          add green num format 8.

quit;

The problem I have now is that I want the columns to be in a specific order. Let's say that I want the new column to be the first one when you read from left.

Does anyone have a clue about how I can do that without creating a new table or read up the whole dateset again(because it takes about one hour)?

Thanks in advance.

4 REPLIES 4
Ksharp
Super User

How about creating a VIEW not TABLE ,if you have a big table .

RW9
Diamond | Level 26 RW9
Diamond | Level 26

Why do you need them in a certain order?  It is irrelevant in programming except in certain situations.  If it is reporting then set the order in the report program.

Kurt_Bremser
Super User

Because the ordering of the columns is part of the physical file layout, you cannot reorder the variables without rewriting the dataset.

Since you also need to rewrite the whole dataset to add a column, you can specify the new ordering at this moment.

a) by specifying the wanted order in the SELECT part of a CREATE TABLE statement in PROC SQL.

b) by specifying the variable ordering in an "empty" FORMAT statement before the SET statement in a DATA step.

BrunoSilva
Quartz | Level 8

There's several techniques to archive this you can check a few in the links bellow, but i think you need always to re-write the table.

Re-ordering variables - sasCommunity

8395 - How to reorder the variables in a SAS® data set

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
  • 4813 views
  • 2 likes
  • 5 in conversation