## How Do I Sum a column that is a calculated by two other columns

Solved
Occasional Contributor
Posts: 6

# How Do I Sum a column that is a calculated by two other columns

[ Edited ]

Hi,

Is it possible during the proc sql code below to add another column which would be 'Total' (Bal1+BAl2+BAl3)-(Bal4+Bal5+Bal6+BAl6)

Or to do it as a seperate data step after the output of the following code?

proc sql;
connect to &ABCD as ABC(ACCDE);
create table TestBal as
select *
from connection to ABC
(
select
AccountNum as Accno,
Bal1,
Bal2,
Bal3,
Bal4,
Bal5,
Bal6,
Bal7,

from Table.Dataset

order by Accno

);
disconnect from ABC;
quit;

Accepted Solutions
Solution
‎11-23-2016 10:15 AM
Super User
Posts: 10,530

## Re: How Do I Sum a column that is a calculated by two other columns

```select
AccountNum as Accno,
Bal1,
Bal2,
Bal3,
Bal4,
Bal5,
Bal6,
Bal7,
(Bal1+BAl2+BAl3)-(Bal4+Bal5+Bal6+BAl6) as Total```
---------------------------------------------------------------------------------------------
Maxims of Maximally Efficient SAS Programmers
How to convert datasets to data steps
How to post code

All Replies
Solution
‎11-23-2016 10:15 AM
Super User
Posts: 10,530

## Re: How Do I Sum a column that is a calculated by two other columns

```select
AccountNum as Accno,
Bal1,
Bal2,
Bal3,
Bal4,
Bal5,
Bal6,
Bal7,
(Bal1+BAl2+BAl3)-(Bal4+Bal5+Bal6+BAl6) as Total```
---------------------------------------------------------------------------------------------
Maxims of Maximally Efficient SAS Programmers
How to convert datasets to data steps
How to post code
Occasional Contributor
Posts: 6