Data have;
input id;
cards;
-1
-2
-3
10
20
30
;
run;
sum of nagative values in positive varible
sum of positive values in negative variable
like below
positive negative
60 -6
Data have;
input id;
if id<0 then negative+id;
else if id>0 then positive+id;
cards;
-1
-2
-3
10
20
30
;
run;
You have negative ID numbers?
Just for fun 🙂
Data have;
input id;
negative + (id<0)*id;
positive + (id>0)*id;
cards;
-1
-2
-2
10
20
30
;
run;
Bart
Just for fun.
Data have;
input id;
cards;
-1
-2
-3
10
20
30
;
proc sql;
select (select sum(id) from have where id>0) as positive,
(select sum(id) from have where id<0) as negative
from have(obs=1);
quit;
April 27 – 30 | Gaylord Texan | Grapevine, Texas
Walk in ready to learn. Walk out ready to deliver. This is the data and AI conference you can't afford to miss.
Register now and lock in 2025 pricing—just $495!
Still thinking about your presentation idea? The submission deadline has been extended to Friday, Nov. 14, at 11:59 p.m. ET.
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.