How can I sum the CHC (in terms of patients and visits)?
@Juli13 wrote:
Yes there is going to be a lot of overlap.
I want to see the total of patients + visits in the year 2012, then 2013, then 2014 and so on.
PROC MEANS.
You need to provide some example data, just enough rows to show what you need. Instructions here: https://communities.sas.com/t5/SAS-Communities-Library/How-to-create-a-data-step-version-of-your-dat... will show how to turn an existing SAS data set into data step code that can be pasted into a forum code box using the {i} icon or attached as text to show exactly what you have and that we can test code against.
And then provide what you want for that example data. Since tabulate can provide sums in rows, columns, pages, within nested variables and overall for the data it really helps to know which subgroups you need the sums for.
Also since your example code has the line:
set services (where = (CHC = "AHL"));
then you can't "sum" chc at all as it is apparently a character variable and SAS does not sum character variables. It can COUNT them but not SUM them.
Sorry for the unclear question- I wish to group together all the CHC year wise and get the total no. of visits and patients for all the services year wise (ie. all the patients and visits for the 2012 for all the services in the year 2012 , 2013...and so on.) Basically I need two variables - year and (total visits + patients) Thank you!
Year | CHC | Service | Visits | Patients |
2012 | AHL | HIV test | 536 | 521 |
2012 | AHL | hepatitis B Test | 85 | 82 |
2012 | AHL | hepatitis C Test | 50 | 47 |
2012 | AHL | mammogram | 274 | 261 |
2012 | AHL | pap test | 1528 | 1416 |
2012 | AHL | selected immunizations | 3037 | 2299 |
2012 | AHL | seasonal flu vaccine | 2048 | 1968 |
2012 | AHL | contraceptive management | 2672 | 1387 |
2012 | AHL | health supervision of infant or child (ages 0 through 11) | 3873 | 2652 |
2012 | AHL | childhood lead test screening (9 to 72 months) | 874 | 839 |
2012 | AHL | SBIRT | 0 | 0 |
2012 | AHL | smoke and tobacco use cessation counseling | 0 | 0 |
2012 | AHL | comprehensive and intermediate eye exam | 0 | 0 |
2012 | AHL | emergency services | 0 | 0 |
2012 | AHL | oral exams | 1268 | 982 |
2012 | AHL | prophylaxis - adult or child | 1376 | 1068 |
2012 | AHL | sealants | 27 | 27 |
2012 | AHL | flouride treatment - adult or child | 955 | 733 |
2012 | AHL | restorative services | 48 | 48 |
2012 | AHL | oral surgery | 1 | 1 |
2012 | AHL | rehabilitative services | 3 | 3 |
2015 | AHL | HIV test | 1265 | 1225 |
2015 | AHL | hepatitis B Test | 63 | 61 |
2015 | AHL | hepatitis C Test | 271 | 260 |
2015 | AHL | mammogram | 1565 | 1502 |
2015 | AHL | pap test | 2095 | 1991 |
Is that what you have or want?
Have you looked at proc freq, means or tabulate? They're probably where you want to start.
This is what I have-I am not able to group all the CHCs and Services together. How can I create a new table with the variables - year and patients+visits). I don't want the CHCs and Services variables.
We still need more information such as what the original raw data looks like. It looks like what you have posted is a desired result which is good. Is your "patients" the number of unique patient identifiers you see in a year and visits the total count of all visits (including duplicates)? If so this may get you started.
proc sort data=work.services; by year patientid; run; data tab; set work.services; by year patientid; Indicator = first.patientid; run; proc tabulate data=tab; class year chc service; var indicator; table year*chc*service*indicator=""*(n='Visits' sum='Patients'); run;
Patientid would be whatever patient unique identifier you have. If you don't have one then you need explain in excructiating detail what the difference in your Visits and Patients results column are and how do we know which is which.
I don't have patient id. I want to see the total of patients + visits in the year 2012, then 2013, then 2014 and so on.
Actually this can't be your input table because if it is you can't Sum patients.
It's 100% likely some patients had multiple service, ie there's probably a big overlap in patients who have HIV and HEP B/C tests.
So you need to go a step back in your process and summarize the data before this step.
Yes there is going to be a lot of overlap.
I want to see the total of patients + visits in the year 2012, then 2013, then 2014 and so on.
@Juli13 wrote:
Yes there is going to be a lot of overlap.
I want to see the total of patients + visits in the year 2012, then 2013, then 2014 and so on.
PROC MEANS.
SAS Innovate 2025 is scheduled for May 6-9 in Orlando, FL. Sign up to be first to learn about the agenda and registration!
Need to connect to databases in SAS Viya? SAS’ David Ghan shows you two methods – via SAS/ACCESS LIBNAME and SAS Data Connector SASLIBS – in this video.
Find more tutorials on the SAS Users YouTube channel.