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
It's finally time to hack! Remember to visit the SAS Hacker's Hub regularly for news and updates.
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.
Ready to level-up your skills? Choose your own adventure.