Is there a way to add percent of the total for each clinic_name into this table?
proc sql ;
create table Gender as
select Clinic_Name,Gender, count(distinct ID)as Distinc_count, sum( Cost) as cost
from have
where Clinic_Type='1' and Cost>1 and SFY='2023'
group by Clinic_Name, Gender;
quit;
This is how I would like it to look:
Thank you!
Looks like you want a report, not a data set. Consider something like this:
proc format;
picture mypct low-high=' 009.9% ';
run;
proc tabulate data=have noseps;
class clinic gender ;
var cost;
table clinic=' ' * gender=' '
, N='Count'*f=5.0 sum=' '*cost='Cost'*f=dollar13.0
cost=' '*pctsum<gender>='%'*f=mypct.
/Box="Clinic Gender" rts=20;
run;
I guess the percents that you want are percent cost for a given gender within a given clinic.
It is not clear what percentage you are talking about.
Why would you use SQL to do that instead of a PROC like TABULATE which is designed to make sure reports?
Looks like you want a report, not a data set. Consider something like this:
proc format;
picture mypct low-high=' 009.9% ';
run;
proc tabulate data=have noseps;
class clinic gender ;
var cost;
table clinic=' ' * gender=' '
, N='Count'*f=5.0 sum=' '*cost='Cost'*f=dollar13.0
cost=' '*pctsum<gender>='%'*f=mypct.
/Box="Clinic Gender" rts=20;
run;
I guess the percents that you want are percent cost for a given gender within a given clinic.
Join us for SAS Innovate 2025, our biggest and most exciting global event of the year, in Orlando, FL, from May 6-9.
Early bird rate extended! Save $200 when you sign up by March 31.
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.
Ready to level-up your skills? Choose your own adventure.