Of course.you can.
proc sql;
create table report as
select 1 as id1,'GENDER' as a length=40,Clinic,
1 as id2,put(Gender,$gender.) as b length=40,
1 as id3,(select count(distinct id) from have where Clinic=a.Clinic and Gender=a.Gender and cost>0) as c format=comma20.,
1 as id4,calculated c/(select count(distinct id) from have where Clinic=a.Clinic and cost>0) as d format=percent8.2,
1 as id5,sum(cost) as e format=dollar20.,
1 as id6,sum(cost)/(select sum(cost) from have where Clinic=a.Clinic) as f format=percent8.2
from have as a
group by Clinic,Gender
union all
select 2 as id1,'ETHNICITY' as a,Clinic,
2 as id2,put(Hispanic,$eth.) as b,
2 as id3,(select count(distinct id) from have where Clinic=a.Clinic and Hispanic=a.Hispanic and cost>0) as c,
2 as id4,calculated c/(select count(distinct id) from have where Clinic=a.Clinic and cost>0) as d format=percent8.2,
2 as id5,sum(cost) as e format=dollar20.,
2 as id6,sum(cost)/(select sum(cost) from have where Clinic=a.Clinic) as f format=percent8.2
from have as a
group by Clinic,Hispanic
;
quit;
... View more