BookmarkSubscribeRSS Feed
🔒 This topic is solved and locked. Need further help from the community? Please sign in and ask a new question.
Gluttony
Fluorite | Level 6

Hi everyone,
I need help for this case :

I have a dataset DATA with columns A, B and C

I want to create a new column D = A + C + G

 

G does not exist in DATA, thus it will create blank for D. But is there a way to set non existing column (G) default values to 0 and then D will be equal to A + C ?

 

Thank you,

Gluttony

1 ACCEPTED SOLUTION

Accepted Solutions
Reeza
Super User

The SUM() statement will ignore missing values.

The SUM operator (+) will not ignore missing values and sets everything to missing when it's blank. 

 

d_operator = a+c+g;
d_statement= sum(a, c, g);

@Gluttony wrote:

Hi everyone,
I need help for this case :

I have a dataset DATA with columns A, B and C

I want to create a new column D = A + C + G

 

G does not exist in DATA, thus it will create blank for D. But is there a way to set non existing column (G) default values to 0 and then D will be equal to A + C ?

 

Thank you,

Gluttony


 

View solution in original post

4 REPLIES 4
PaigeMiller
Diamond | Level 26

@Gluttony wrote:

Hi everyone,
I need help for this case :

I have a dataset DATA with columns A, B and C

I want to create a new column D = A + C + G

 

G does not exist in DATA, thus it will create blank for D. But is there a way to set non existing column (G) default values to 0 and then D will be equal to A + C ?

 

Thank you,

Gluttony


D = A + C + 0;

or

 

D = A + C;
--
Paige Miller
novinosrin
Tourmaline | Level 20

 

retain g 0;

d=sum(a,c,g);

 

Reeza
Super User

The SUM() statement will ignore missing values.

The SUM operator (+) will not ignore missing values and sets everything to missing when it's blank. 

 

d_operator = a+c+g;
d_statement= sum(a, c, g);

@Gluttony wrote:

Hi everyone,
I need help for this case :

I have a dataset DATA with columns A, B and C

I want to create a new column D = A + C + G

 

G does not exist in DATA, thus it will create blank for D. But is there a way to set non existing column (G) default values to 0 and then D will be equal to A + C ?

 

Thank you,

Gluttony


 

Gluttony
Fluorite | Level 6

Thank you all for your answers !

Gluttony

SAS Innovate 2025: Call for Content

Are you ready for the spotlight? We're accepting content ideas for SAS Innovate 2025 to be held May 6-9 in Orlando, FL. The call is open until September 25. Read more here about why you should contribute and what is in it for you!

Submit your idea!

How to Concatenate Values

Learn how use the CAT functions in SAS to join values from multiple variables into a single value.

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
  • 917 views
  • 4 likes
  • 4 in conversation