/ Published in: SAS
Using Proc SQL summarize the table sashelp.shoes grouping on
Expand |
Embed | Plain Text
Copy this code and paste it in your HTML
/*Taken from thread http://groups.google.com/group/comp.soft-sys.sas/browse_thread/thread/8cdec58cd0846e29?hl=en*/ /*Method 1*/ proc sql feedback; *describe table dictionary.columns; select catx(' ','Sum(',name,') as', Name,ifc(not missing(format),cats('format=',format),' ')) into :sumlist separated by ', ' from dictionary.columns where libname eq 'SASHELP' and memname eq 'SHOES' and type eqt 'n' ; %put NOTE: &numlist; select region, product, &sumlist from sashelp.shoes group by region, product ; quit; run; /*Method 2*/ proc sql; select region, product, sum(stores) as sumstores, sum(sales) as sumsales, sum(inventory) as suminventory, sum(returns) as sumreturns from sashelp.shoes group by region, product; quit;