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.
Available on demand!
Missed SAS Innovate Las Vegas? Watch all the action for free! View the keynotes, general sessions and 22 breakouts on demand.
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.
Select SAS Training centers are offering in-person courses. View upcoming courses for: