05-26-2015 04:50 AM
I have a table with 16 million rows and I would to add a column to the table which I did with :
alter table A
add green num format 8.
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.
05-26-2015 09:05 AM
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.
05-26-2015 09:15 AM
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.
05-26-2015 11:27 AM
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.