BookmarkSubscribeRSS Feed
SASPhile
Quartz | Level 8
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%
1 REPLY 1
sbb
Lapis Lazuli | Level 10 sbb
Lapis Lazuli | Level 10
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.

hackathon24-white-horiz.png

The 2025 SAS Hackathon has begun!

It's finally time to hack! Remember to visit the SAS Hacker's Hub regularly for news and updates.

Latest Updates

How to Concatenate Values

Learn how use the CAT functions in SAS to join values from multiple variables into a single value.

Find more tutorials on the SAS Users YouTube channel.

SAS Training: Just a Click Away

 Ready to level-up your skills? Choose your own adventure.

Browse our catalog!

Discussion stats
  • 1 reply
  • 940 views
  • 0 likes
  • 2 in conversation