proc sql;
/* test data */
create table one (year num, qtr num, sales num);
insert into one
values (2009, 1, 1000)
values (2009, 2, 1000)
values (2009, 3, 1000)
values (2009, 4, 1000)
values (2010, 1, 1550)
values (2010, 2, 1550)
values (2010, 3, 1550)
values (2010, 4, 1550);
/* attach yearly sum */
create table two as
select year, qtr, sales format=dollar8.
, sum(sales) as total format=dollar8.
from one
group by year
order by year, qtr;
/* check */
select * from two;
/* on lst
year qtr sales total
--------------------------------------
2009 1 $1,000 $4,000
2009 2 $1,000 $4,000
2009 3 $1,000 $4,000
2009 4 $1,000 $4,000
2010 1 $1,550 $6,200
2010 2 $1,550 $6,200
2010 3 $1,550 $6,200
2010 4 $1,550 $6,200
*/
quit;
Join us for SAS Innovate 2025, our biggest and most exciting global event of the year, in Orlando, FL, from May 6-9. Sign up by March 14 for just $795.
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.