Help using Base SAS procedures

adding a new column to a table

Accepted Solution Solved
Reply
Occasional Contributor
Posts: 13
Accepted Solution

adding a new column to a table

hi,

I am trying to add a column to an existing table and I want al, the rows in the column to have a value 1

i used this syntax, but it didn't work;

newcolumn = 1

any help?


Accepted Solutions
Solution
‎07-19-2011 09:08 AM
PROC Star
Posts: 7,487

adding a new column to a table

How about:

data want;

  set sashelp.class;

  retain newcolumn 1;

run;

HTH,

Art

View solution in original post


All Replies
Frequent Contributor
Frequent Contributor
Posts: 94

adding a new column to a table

Your suggestion sounds like it should have worked (although using RETAIN to set a default value is probably more efficient), e.g.

data mydata;

set mydata;

newcolumn = 1;

run;

or

data mydata;

set mydata;

retain newcolumn 1;

run;

Are you getting an error of some kind?

Occasional Contributor
Posts: 13

adding a new column to a table

Thanks DF, your response helped me spot my error.

It is fine now.

Solution
‎07-19-2011 09:08 AM
PROC Star
Posts: 7,487

adding a new column to a table

How about:

data want;

  set sashelp.class;

  retain newcolumn 1;

run;

HTH,

Art

🔒 This topic is solved and locked.

Need further help from the community? Please ask a new question.

Discussion stats
  • 3 replies
  • 173 views
  • 3 likes
  • 3 in conversation