☑ This topic is solved.
Need further help from the community? Please
sign in and ask a new question.
- Mark as New
- Bookmark
- Subscribe
- Mute
- RSS Feed
- Permalink
- Report Inappropriate Content
Posted 03-26-2024 03:32 PM
(549 views)
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!
1 ACCEPTED SOLUTION
Accepted Solutions
- Mark as New
- Bookmark
- Subscribe
- Mute
- RSS Feed
- Permalink
- Report Inappropriate Content
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.
--------------------------
The hash OUTPUT method will overwrite a SAS data set, but not append. That can be costly. Consider voting for Add a HASH object method which would append a hash object to an existing SAS data set
Would enabling PROC SORT to simultaneously output multiple datasets be useful? Then vote for
Allow PROC SORT to output multiple datasets
--------------------------
The hash OUTPUT method will overwrite a SAS data set, but not append. That can be costly. Consider voting for Add a HASH object method which would append a hash object to an existing SAS data set
Would enabling PROC SORT to simultaneously output multiple datasets be useful? Then vote for
Allow PROC SORT to output multiple datasets
--------------------------
2 REPLIES 2
- Mark as New
- Bookmark
- Subscribe
- Mute
- RSS Feed
- Permalink
- Report Inappropriate Content
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?
- Mark as New
- Bookmark
- Subscribe
- Mute
- RSS Feed
- Permalink
- Report Inappropriate Content
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.
--------------------------
The hash OUTPUT method will overwrite a SAS data set, but not append. That can be costly. Consider voting for Add a HASH object method which would append a hash object to an existing SAS data set
Would enabling PROC SORT to simultaneously output multiple datasets be useful? Then vote for
Allow PROC SORT to output multiple datasets
--------------------------
The hash OUTPUT method will overwrite a SAS data set, but not append. That can be costly. Consider voting for Add a HASH object method which would append a hash object to an existing SAS data set
Would enabling PROC SORT to simultaneously output multiple datasets be useful? Then vote for
Allow PROC SORT to output multiple datasets
--------------------------