provider drugname totalsales
ABC mydrug 250
ABC comp1 100
ABC mydrug 250
ABC comp2 100
ABC comp3 100
PQR mydrug 250
PQR comp1 100
pqr mydrug 250
pqr comp2 100
pqr comp3 100
For the above data I need to generate output this way.
Note:The numbers are arbitrary.This is only to show how the data looks and how the output must look.In real data, I have around 20 providers and 7 different drugs.
The percentage shows the percentage of the drug sales.
I tried this creating 20 different datasets for each drug and its sum and percentage.This is tedious in a way.
Any help is appreciated.
Provider totalpres mydrug comp1 comp2 mydrug comp3
ABC 1000 250 30% 20% 25% 25%
PQR 500 250 15% 20% 50% 25%