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.

sas-innovate-2024.png

Join us for SAS Innovate April 16-19 at the Aria in Las Vegas. Bring the team and save big with our group pricing for a limited time only.

Pre-conference courses and tutorials are filling up fast and are always a sellout. Register today to reserve your seat.

 

Register now!

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.

Click image to register for webinarClick image to register for webinar

Classroom Training Available!

Select SAS Training centers are offering in-person courses. View upcoming courses for:

View all other training opportunities.

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