Hello all. I have had a four year break from coding DB SQL, and now I am taking a course in SAS Enterprise Guide. I was given an assignment to pull a percentage from 2 range variables. One range is for high medical codes, and the other is for low medical codes. Below is a screen shot of the directions.
Below is a yes/no data scenario of the records that would be pulled.
HN=Hospital_Num
COD=Proc_Code
CT= Total Claim Count for Proc_Code
Include Yes/No = my explanation of why a record would be included in the report.
Output Example
My code is generated in EG. My code gives a count of the different codes. What I need is to get a total of the high range codes ('14','15') and divide this by a total of all code counts grouped by hospital. This is where I can get a percentage of the high code counts each hospital has. I believe this might be done with compound case statements. I used case statements to get the counts of the individual counts. See Code below.
PROC SQL;
CREATE TABLE DBS.t_flags AS
SELECT DISTINCT t1.HN,
t1.COD,
/* sum_code */
(SUM((CASE
WHEN t1.COD between '14' and '15'
THEN 1
when t1.cod not between '14' and '15'
then 1
else 0
end))) AS sum_cod
FROM DBS.T_DETAIL t1
GROUP BY t1.BN,
t1.COD
ORDER BY t1.BN,
QUIT;
Any assistance would be greatly appreciated. I would like to become an expert in Proc SQL, and even data step. It would be great if I learn enough to help others out on this website.
Sincerely,
Edward