DATA Step, Macro, Functions and more

Proc repot

Super Contributor
Posts: 647

Proc repot

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%
Super Contributor
Super Contributor
Posts: 3,174

Re: Proc repot

Suggest a DATA step to prepare your data (hint: UPCASE on provider), then PROC TRANSPOSE (vertical data to horizontal) using BY. Then PROC PRINT or PROC REPORT.

Scott Barry
SBBWorks, Inc.
Ask a Question
Discussion stats
  • 1 reply
  • 2 in conversation