Hi - I have a dataset where each record is a count of how many times a physician prescribed a certain drug. I would like to calculate how many times each physician prescribed opioids and nonopioids so that I can classify the physician as a "high subscriber" if the count of opioids is over a certain number.
Does anyone have any advice on how I can approach this problem?
Thanks
AMT
You (or someone) has to classify each drug prescribed as either opioid or non-opioid. Then PROC FREQ will count the number of times each physician prescribes opioid or non-opioid.
... so that I can classify the physician as a "high subscriber" if the count of opioids is over a certain number.
Shouldn't that say: if the percent of opioids is over some pre-determined percent?
I have the drugs specified as either opioid or nonopioid. PROC FREQ gives me the variables individually. I want FREQ by provider
Angie
I am using SAS for Academics. Everytime I run this, I get an error that SAS needs to close.
PROC FREQ DATA=WORK
tables npi*class;
run;
This is a subset of the data. I could not load the entire file as it is too large.
If we only get partial information then it's a bit hard to really know where things don't work for you.
Have you already read these guidelines here?
For the code you've just posted: Looks like there is a semicolon missing after the Proc part of the statement.
PROC FREQ DATA=WORK.want;
tables npi*class;
run;
@AMMAN wrote:
I am using SAS for Academics. Everytime I run this, I get an error that SAS needs to close.
PROC FREQ DATA=WORK
tables npi*class;
run;
This is a subset of the data. I could not load the entire file as it is too large.
What is in the Excel file is irrelevant here. One of the things that you can do is to actually look at the SAS data set WORK (not the Excel file) and see if you can find something wrong; or if it looks okay. If something looks wrong and you can't figure out how to fix it, then we need to see a portion of the SAS data set (following these instructions) and not the original Excel file.
(And as @Patrick said, make sure you fix obvious errors in your code before coming here to ask further questions, such as fixing the missing semi-colon issue he mentions)
You're quick to assume the missing semi-colon wasn't an innocent mistake. I keyed the code in the chat box quickly because my cut and paste from EG was lost when I tried to attach the full file which caused an error.
This is a beginner's forum. You could try to be friendly.
I can assure you that we all try to be friendly. But please try to understand our suggestions. Our only goal is to help you solve your problem.
@AMMAN wrote:
I am using SAS for Academics. Everytime I run this, I get an error that SAS needs to close.
PROC FREQ DATA=WORK
tables npi*class;
run;
This is a subset of the data. I could not load the entire file as it is too large.
If you intended to use a count variable, such as your bene_count to indicate the number of times that provide did something you would use that variable on a WEIGHT statement. Otherwise each of those records only gets counted for one prescription.
One thing you might try is to add NOPRINT to the proc statement as the table output in the results could be excessive.
PROC FREQ DATA=WORK noprint; tables npi*class / out=work.freq (drop=percent); weight bene_count; run;
I think that I might be tempted to include a row percentage. Consider if you pick 700 as your "count" of opioids to be "high"?
If you have one provider with 500 prescriptions and 490 of them are opioids you wouldn't see that one as "high" but another provider with 100,000 total prescriptions and 701 would be. The first having 98 percent opioids wouldn't meet the threshold but the other with 0.7 percent would. So I might consider a percentage of opioid prescriptions coupled with a minimum number of total prescriptions.
Something like:
PROC FREQ DATA=WORK noprint; tables npi*class / outpct out=work.freq (drop=percent pct_col); weight bene_count; run;
Registration is now open for SAS Innovate 2025 , our biggest and most exciting global event of the year! Join us in Orlando, FL, May 6-9.
Sign up by Dec. 31 to get the 2024 rate of just $495.
Register now!
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.