Hi, I'm a new SAS user, and I could use some help. I would like to be able to look at frequency (or counts) over time. My data set has 80 days, and for each day, there is a value representing appointment attendance (e.g., attended, missed due to illness, missed due to holiday, etc.). My data looks like this:
ID typeday1 typeday2 typeday3 typeday4 .......up to typeday80
1 3 2 3 2
2 4 2 4 3
What I'd like to be able to do is:
a) find out, looking across all 80 days, how many appointments each person attended (e.g., 2s), how many did they miss due to holiday (e.g., 3), etc.
b) somehow looking across every person and every day overall, how many appointments were missed for each reason.
Any suggestions for how to accomplish this would be great.
These two reports are examples of what you can do with PROC TABULATE. If you keep the data "wide", so that all the info for one patient is on one obs, then your choice to count is to use array processing. If you use PROC TRANSPOSE to turn the wide data into long and skinny data, then other procedures open up to you for reporting.
In addition, you can create user-defined formats, like the ones below, that would allow you to display a meaningful label, such as "Appt Attended" or "Miss Holiday" instead of codes 2 or 3. Or, formats could even be used to associate a name with an id.
Cynthia, I think for now I would like to keep the data wide and use an array like you suggested to count across appointment days. Because then I could use the "count" generated in other analyses. Do you have any suggestions of what such an array might look like?
There are 10 appointment days, and on each day you could have any one of 5 outcomes (e.g., attended, missed because doctor cancelled, missed because sick, missed because holiday, missed for personal reasons).
What I'd eventually like to be able to say is that across all participants and all appointment days, X% of appointments were attended, X% were missed because the doctor cancelled, etc.
There is an alternative, however, to using arrays.
You can keep the data in whatever form you want -- you can keep it long and wide for storage and reference and data entry purposes. But then you can create temporary datasets to do all the countring.
SAS has some perfectly wonderful procedures that do counts and percents --and-- if the data is in the right form, will give you ALL the information you want, either in report form or in dataset form.
Without knowing how you need to use the counts in other analysis, it's hard to make a recommendation about whether arrays are best or whether looking at PROC TRANSPOSE and PROC FREQ are best. Generally, I recommend starting with TRANSPOSE and FREQ or TRANSPOSE and TABULATE for beginners -- because it is easier, sometimes to deal with a self-contained procedure that only does 1 thing than to jump into DATA step processing, where the syntax and the process can sometimes be challenging.