im trying to sum the previous number
intial total number is Num_1 + num_2 and than after its Num_2+total
Have:
date num_1 Num_2
06JAN2019 5 10 13JAN2019 5 10 20JAN2019 5 10 27JAN2019 5 10
want
date num_1 Num_2 total
06JAN2019 5 10 1513JAN2019 5 10 2520JAN2019 5 10 3527JAN2019 5 10 45
Do like this
data have; input date:date9. num_1 Num_2; format date date9.; datalines; 06JAN2019 5 10 13JAN2019 5 10 20JAN2019 5 10 27JAN2019 5 10 ; data want; set have; if _N_=1 then total=sum(num_1, num_2); else total=total+num_2; retain total; run;
View solution in original post
data have; input date :date9. num_1 Num_2 ; format date date9.; cards; 06JAN2019 5 10 13JAN2019 5 10 20JAN2019 5 10 27JAN2019 5 10 ; data want; set have; if _n_=1 then total+sum(num_1 ,Num_2); else total+ Num_2; run;
April 27 - 30 | GAYLORD TEXAN
Register now to lock in early bird pricing through February 25!
SAS' Charu Shankar shares her PROC SQL expertise by showing you how to master the WHERE clause using real winter weather data.
Find more tutorials on the SAS Users YouTube channel.