In sashelp there is a file name countseries (FOR SAS UNIVERSITY EDITION) , how can i make jan2004 to dec2004 into one major category as'2004 and add up all the units for 2004 and make a table consisting of only year and total units in that particular year.
Can anyone please explain this with the code.
Thank you.
data countseries;
set sashelp.countseries;
year=year(date);
run;
proc sql;
create table want as select year, sum(units) as sum from countseries group by year;
quit;
data countseries;
set sashelp.countseries;
year=year(date);
run;
proc sql;
create table want as select year, sum(units) as sum from countseries group by year;
quit;
thank you sir
The solution should be just one pass of sql.
A datastep to compute year and then proc sql for by group is very costly.
select clause can be used to compute year
and the computed column can be used as grouping var.
I agree with you @novinosrin, the code could simplified in one step proc sql as below
proc sql;
create table want as select year(date) as year, sum(units) as sum from sashelp.countseries group by year;
quit;
SAS Innovate 2025 is scheduled for May 6-9 in Orlando, FL. Sign up to be first to learn about the agenda and registration!
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.