Group by date using proc sql in SAS -


i want sum values same cost centre per each year in sas. tried group function in proc sql.

proc sql      create table incident_data          select   cost_centre_dim.cost_centre_name,                  sum(count*amount) tot,                  occ_date format= year4.              incidents,                  incident_type,                  cost_centre_dim             incidents.incident_code = incident_type.incident_code         ,      incidents.cost_centre_id = cost_centre_dim.cost_centre_id         group cost_centre_dim.cost_centre_name,                  occ_date          order [cost centre dim].[cost centre name];  quit; run; 

the output looks below:

2012  34.41  acci2  2012  34.23  acci2  2014  25.71  infr1  2014  27.82  infr1  2014  22.26  infr2  2014  20.97  infr2  2013  22.64  acci4  2013  19.29  acci4  2013  18.26  acci4  2014  35.82  acci4  2015  97.81  infr3  2015  44.04  infr3  2014  57.09  infr3  

i want output show 1 line 1 type of incident per year add amount. sth this:

2012  68.64  acci2   2014  53.53  infr1   2014  43.23  infr2   ...  

any advice appreciated

try converting occ_date text this: put(occ_date, year4) myocc_date

i think original code displaying date in format assigned still actual numerical value of occ_date. if change character in format want should grouping correctly.


Comments

Popular posts from this blog

Java 3D LWJGL collision -

spring - SubProtocolWebSocketHandler - No handlers -

methods - python can't use function in submodule -