proc freq data=have;
tables id*service/list;
run;
@edwardar126 wrote:
Thank you for the suggestion. I actually did this, but my concern being that since my dataset is 100,000+ I get a large list of patients and I would still need to group each individuals. I'm thinking about creating another variable for this step.
Then, you have not yet described what you do want in enough detail to help.
Then you run PROC FREQ twice. The first time you use tables id*service/out=_a_ noprint; and save the results in a SAS data set. The second time you run PROC FREQ on data set _a_ with tables count;
It helps to show what you would expect as a result from your given example data.
I can see something like using Proc Freq to count the person/service combinations sending that to a data set and then summarizing the "count" by the service type. Not terribly difficult or complex but we do need to know what you want as a final result.
Proc SQL gives you lots of flexibility to do this kind of grouping:
proc sql;
create table want as
select
count(id) as count,
*
from have
group by ID, service;
quit;
Count ID Date Agency Service 2 12 2020-05-01 Hospital A Lab Work 2 12 2020-05-05 Clinic D Lab Work 1 12 2020-05-01 Hospital A X Ray 1 14 2020-05-01 Hospital A MRI 1 14 2020-05-01 Hospital A Physical Therapy 1 20 2020-05-03 Hospital B Lab Work 3 21 2020-05-10 Clinic D Lab Work 3 21 2020-05-05 Hospital A Lab Work 3 21 2020-05-01 Hospital A Lab Work 1 21 2020-05-01 Community Clinic Physical Therapy 1 21 2020-05-05 Hospital A Referral 1 21 2020-05-01 Hospital A X Ray
SAS Innovate 2025 is scheduled for May 6-9 in Orlando, FL. Sign up to be first to learn about the agenda and registration!
ANOVA, or Analysis Of Variance, is used to compare the averages or means of two or more populations to better understand how they differ. Watch this tutorial for more.
Find more tutorials on the SAS Users YouTube channel.