I'm working on creating a summary report using proc report. below is the sample of my dataset
category | month | count |
category1 | 201801 | 245 |
category1 | 201802 | 335 |
category1 | 201803 | 12 |
category2 | 201801 | 78 |
category2 | 201802 | 65 |
category2 | 201803 | 34 |
category3 | 201801 | 76 |
category3 | 201802 | 55 |
category3 | 201803 | 88 |
I want to create something like this,
| category1 | category2 | Percentage_increase | category2 | category3 | percentage_increase |
201801 | 245 | 78 | -0.681632653 | 78 | 76 | -0.025641026 |
201802 | 335 | 65 | -0.805970149 | 65 | 55 | -0.153846154 |
201803 | 12 | 34 | 1.833333333 | 34 | 88 | 1.588235294 |
my code is,
proc report data = membership_data;
column month category,count Percentage_change1 Percentage_change2;
define month / group ;
define category / across ;
define count/' ';
define Percentage_change1/computed format=percent8.2;
compute Percentage_change1;
Percentage_change1 = (_c3_-_c2_)/_c2_;
endcomp;
define Percentage_change2/computed format=percent8.2;
compute Percentage_change2;
Percentage_change2 = (_c4_-_c3_)/_c3_;
endcomp;
run;
after running above proc report, I end up having summary table like this
| category1 | category2 | category3 | Percentage_increase1 | percentage_increase2 |
201801 | 245 | 78 | 76 | -0.681632653 | -0.026315789 |
201802 | 335 | 65 | 55 | -0.805970149 | -0.181818182 |
201803 | 12 | 34 | 88 | 1.833333333 | 0.613636364 |
my goal is to use the column 'category2' twice and rearrange the order. how to implement this.
Any inputs are appreciated