From: A. S. on
What's the best way to add non-existing columns without modifying
those of these that might already be present?
From: Richard A. DeVenezia on
On Jul 7, 4:30 am, "A. S." <the.gere...(a)googlemail.com> wrote:
> What's the best way to add non-existing columns without modifying
> those of these that might already be present?

You can use Proc SQL; alter table <name> add <column-def>, <column-
def>

Alter will modify existing columns, so you should use caution.

--
Richard A. DeVenezia
http://www.devenezia.com
From: A. S. on
Thanks! That's a start. So how can I avoid modifying already existing
columns?
From: Tom Abernathy on
On Jul 7, 12:07 pm, "A. S." <the.gere...(a)googlemail.com> wrote:
> Thanks! That's a start. So how can I avoid modifying already existing
> columns?

Use a DATA step to make the NEW dataset with the new columns. The
order of when the variables are first defined will determine the
attributes.
For example this code will add two "empty" columns VAR1 and VAR2 and
set the type and length. BUT if the columns already exist then SAS
will NOT change the type or length and will give you a warning in the
log.

data new;
set old;
length VAR1 $10 VAR2 8 ;
run;

Now if you DO want to modify the column then you need to define it
BEFORE setting the old data. For example if I want to make VAR1
longer so I can do this.

data new2;
length var1 $20 ;
set new;
run;