Try: proc summary data=your_data nway; class area period ; var n pop; output out=mysums sum= nsum popsum; run; proc print data=work.mysums; run; Unless you need "by statements" you do not need to sort the input to proc summary; If you add age and sex to the class statement and drop the nway option from the proc statement you will get all possible classifications of your class variables; You can then use the value of _type_ in the output data set to select which classification scheme you want to explore for further analysis; (I believe that you have a typo in lines 1 & 2 of the code your are presenting.)
... View more