BookmarkSubscribeRSS Feed
NewUsrStat
Pyrite | Level 9

I have the following table:

 

Screen Shot 2023-04-17 at 12.06.51.png

Suppose to look at Drug3 dosage 0.75 and 1.5. Is there a way with proc tabulate or another proc to compute the percentage on 21520 + 34732? In other words, the percentage for 0.75 should be 21520/(21520 + 34732)=38% and for 1.5 should be 34732/(21520 + 34732)=61%

Thank you in advance

2 REPLIES 2
Ksharp
Super User
I think PROC SQL can do that.
Can you post your data and the output you want?
ballardw
Super User

Please show your existing Proc Tabulate code.

 

If you do not want the missing values for your dosage_3m variable included in the denominators for Pctn calculations then you need to exclude them, such as not include MISSING on the class statement for that variable.

 

If you want to include the missing then you will have to modify the data and pick another approach to get something like this in proc tabulate. One approach would be to add another variable has a value of 1 only when Dosage_3m is not missing and then use that variable as a Var variable and ColPctSum with that variable instead of ColPctN of the Class variable.

 

 

SAS Innovate 2025: Call for Content

Are you ready for the spotlight? We're accepting content ideas for SAS Innovate 2025 to be held May 6-9 in Orlando, FL. The call is open until September 16. Read more here about why you should contribute and what is in it for you!

Submit your idea!

Mastering the WHERE Clause in PROC SQL

SAS' Charu Shankar shares her PROC SQL expertise by showing you how to master the WHERE clause using real winter weather data.

Find more tutorials on the SAS Users YouTube channel.

Discussion stats
  • 2 replies
  • 476 views
  • 0 likes
  • 3 in conversation