Link to home
Start Free TrialLog in
Avatar of premkripalani
premkripalaniFlag for Australia

asked on

SAS EG - New Column

hi
I would like to create a new column  with defult value. may i know how to do this?
for ex. I wan a new column "State" and I want to assign "NSW" to all the records.
thanks
Avatar of Aloysius Low
Aloysius Low
Flag of Singapore image

are you writing a code to do so? are you using any UI e.g. Enterprise Guide?

for code:
data [libname].[table name];
  set [libname].[table name];
  length [field] $[max length].;  <-- for numeric fields it'll be length [field] [length in bits min 3 max 8].;
  [field] = "[value]";  <-- no quotation marks for numeric values
run;

using the UI is another story, depending on the UI.
Avatar of premkripalani

ASKER

sorry, I am using enterprise guide
thanks
you could still try to run the code - that is universal across versions of enterprise guide. but for EG4.2, i'm not too sure how different it is from EG4.1 which i am currently using.

for EG4.1, you'll need to open the table and unprotect the data (turn off read-only), then select a column and right click. you should be able to select insert a column. on the resulting dialog box, you can specify the column name, description, type, length, format, informat, and default value (including using an expression to derive the value) for the new column. again, i'm not sure how this differs in EG4.2
i am able to create a new column but i can't find "default" value option in the properties, where it is exactly please.
ASKER CERTIFIED SOLUTION
Avatar of Aloysius Low
Aloysius Low
Flag of Singapore image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
great,