Summing a Column By Group In a Dataset With Macros

前端 未结 3 452
说谎
说谎 2021-01-27 11:34

I have a dataset that looks like:

 Month   Cost_Center      Account    Actual    Annual_Budget
 June     53410           Postage       13      234
 June     5342         


        
3条回答
  •  情深已故
    2021-01-27 12:16

    1. Use PROC MEANS to summarize the data
    2. Use a data step and IF/THEN statement to create your flags.

      proc means data=have N SUM NWAY STACKODS;
         class account;
         var amount annual_budget;
         ods output summary = summary_stats1;
         output out = summary_stats2 N = SUM= / AUTONAME;
      run;
      
      data want;
        set summary_stats;
        if sum_actual > sum_annual_budget then flag=1; 
        else flag=0;
      run;
      

提交回复
热议问题