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
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 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;
retain g 0;
d=sum(a,c,g);
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
Thank you all for your answers !
Gluttony
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!
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.