Hi -
I would like to obtain a count of ED visits and hospital admissions that occurred within 90 days by type and location (inside facility vs all other outside facilities/hospitals). I've spent the entire morning and most of the afternoon trying to figure this out to no avail. Your help is greatly appreciated!
Actual sample size = 1290
I want to count the number of visits with respective to visit type and visit facility.
Variables of interest:
NC1 - NC6: 1 = ED visit, 2 = Hospital admission
NC1LOC - NC6LOC: 20 = Inside facility, 21 - 49 = All other outside facilities
I've manually counted the number of visits by each type and facility for the first observation to give you an idea of what I need help with (please see last 4 columns in the table).
Also, I wonder if there's another way (besides proc sort) to organize the visit dates for each row (observation) so that they are in ascending order. This isn't a pressing need at the moment but would be helpful for future reference. Thank you so much!
Sample data set
INQFROM | INQTO | NC1 | NC1LOC | NC1ADMIT | NC1DISCHARGE | NC2 | NC2LOC | NC2ADMIT | NC2DISCHARGE | NC3 | NC3LOC | NC3ADMIT | NC3DISCHARGE | NC4 | NC4LOC | NC4ADMIT | NC4DISCHARGE | NC5 | NC5LOC | NC5ADMIT | NC5DISCHARGE | NC6 | NC6LOC | NC6ADMIT | NC6DISCHARGE | IN_ED | IN_HOSPITAL | OUT_ED | OUT_HOSPITAL |
12/23/2017 | 3/23/2018 | 1 | 20 | 2/9/2018 | 2/9/2018 | 1 | 20 | 2/19/2018 | 2/19/2018 | 1 | 20 | 2/25/2018 | 2/25/2018 | 1 | 20 | 3/5/2018 | 3/5/2018 | 1 | 20 | 3/18/2018 | 3/18/2018 | 1 | 27 | 3/22/2018 | 3/22/2018 | 5 | 0 | 1 | 0 |
12/14/2017 | 3/14/2018 | 1 | 20 | 12/20/2017 | 12/20/2017 | 2 | 20 | 12/20/2017 | 12/22/2017 | 1 | 20 | 1/10/2018 | 1/10/2018 | 2 | 20 | 1/10/2018 | 1/12/2018 | 2 | 26 | 1/15/2018 | 1/16/2018 | 2 | 20 | 1/26/2018 | 1/27/2018 | ? | ? | ? | ? |
10/28/2017 | 1/26/2018 | 1 | 23 | 11/2/2017 | 11/2/2017 | 2 | 23 | 11/2/2017 | 11/8/2017 | 2 | 20 | 11/8/2017 | 11/16/2017 | 1 | 20 | 12/11/2017 | 12/11/2017 | 2 | 20 | 12/11/2017 | 12/17/2017 | ? | ? | ? | ? | ||||
6/29/2018 | 9/27/2018 | 1 | 20 | 7/20/2018 | 7/20/2018 | 2 | 27 | 7/26/2018 | 1 | 27 | 7/19/2018 | 7/19/2018 | 1 | 27 | 7/5/2018 | 7/5/2018 | 2 | 27 | 7/26/2018 | 7/30/2018 | ? | ? | ? | ? | |||||
9/5/2017 | 12/4/2017 | 1 | 27 | 9/23/2017 | 9/23/2017 | 1 | 27 | 9/23/2017 | 9/24/2017 | 2 | 27 | 9/29/2017 | 10/9/2017 | 1 | 27 | 10/17/2017 | 10/17/2017 | 1 | 23 | 10/18/2017 | 10/18/2017 | ? | ? | ? | ? | ||||
5/6/2018 | 8/4/2018 | 2 | 44 | 5/9/2018 | 5/11/2018 | 2 | 44 | 5/24/2018 | 5/24/2018 | 2 | 20 | 5/7/2018 | 5/9/2018 | 2 | 20 | 6/17/2018 | 6/19/2018 | ? | ? | ? | ? | ||||||||
6/5/2019 | 9/3/2019 | 1 | 28 | 7/13/2019 | 7/13/2019 | 2 | 28 | 7/15/2019 | 7/17/2019 | 2 | 44 | 7/17/2019 | 7/22/2019 | ? | ? | ? | ? | ||||||||||||
4/11/2019 | 7/10/2019 | 1 | 31 | 4/20/2019 | 4/20/2019 | 1 | 20 | 6/12/2019 | 6/12/2019 | 1 | 31 | 6/16/2019 | 6/16/2019 | ? | ? | ? | ? | ||||||||||||
11/10/2016 | 2/8/2017 | 1 | 20 | 11/10/2016 | 11/10/2016 | 2 | 20 | 11/22/2016 | 11/28/2016 | 2 | 20 | 12/7/2016 | 12/9/2016 | ? | ? | ? | ? | ||||||||||||
6/6/2019 | 9/4/2019 | 2 | 23 | 7/9/2019 | 2 | 23 | 7/31/2019 | 8/2/2019 | 2 | 23 | 8/29/2019 | 9/4/2019 | 2 | 23 | 8/29/2019 | 9/4/2019 | ? | ? | ? | ? |
@Kimberly09 wrote:
Also, I wonder if there's another way (besides proc sort) to organize the visit dates for each row (observation) so that they are in ascending order. This isn't a pressing need at the moment but would be helpful for future reference. Thank you so much!
In a SAS data step, the CALL SORTN function will organize the visit dates for each row in ascending order. Example: https://documentation.sas.com/?docsetId=lefunctionsref&docsetTarget=p0exzteatvicqkn1bzyzs0qaecy1.htm...
You might want to consider renaming the variables such that the number is at the end, this will enable you to refer to your variables as nc_admit1-nc_admit12, which is much easier than typing all of them out.
Are you ready for the spotlight? We're accepting content ideas for SAS Innovate 2025 to be held May 6-9 in Orlando, FL. The call is open until September 25. Read more here about why you should contribute and what is in it for you!
Learn how use the CAT functions in SAS to join values from multiple variables into a single value.
Find more tutorials on the SAS Users YouTube channel.