Hi folks,
I am trying to do the following;
My data looks like below. For each ID there can be multiple Epi_number. I want to count a record having same ID and Start_date and Dis_date as one admission regardless of Epi_number. For example ID 02 has three Epi_number and I want to take these three rows as one admission. Can someone suggest what to do please?
TaData Admissions_qtr;
input ID Epi_number Start_date Dis_date;
datalines;
01 1 01Jan2012 03Jan2012
02 1 17Mar2014 19Mar2014
02 2 17Mar2014 19Mar2014
02 3 17Mar2014 19Mar2014
03 1 19May2015 25May2015
03 2 19May2015 25May2015
03 3 19May2015 25May2015
03 4 19May2015 25May2015
;
run;
Doctor isn't sure what to order 🙂 ? and
For what it's worth, i am posting this
Data Admissions_qtr;
infile cards expandtabs truncover;
input ID $ Epi_number (Start_date Dis_date) (:date9.);
format Start_date Dis_date date9.;
datalines;
01 1 01Jan2012 03Jan2012
02 1 17Mar2014 19Mar2014
02 2 17Mar2014 19Mar2014
02 3 17Mar2014 19Mar2014
03 1 19May2015 25May2015
03 2 19May2015 25May2015
03 3 19May2015 25May2015
03 4 19May2015 25May2015
;
run;
data want;
set Admissions_qtr;
by id Start_date Dis_date;
group_var=first.Dis_date;
run;
Just to say, there are 77650 rows in my data set
Not sure, how to imagine your expected output and guess. Can you post the expected sample too plz for the posted input
That's exactly what I am not sure about but I am assuming it will look like this;
Also I would like to sum up all 'admissions' for each month so I am assuming that it should give the desired output
TaData Admissions_qtr;
input ID Epi_number Start_date Dis_date Admissions;
datalines;
01 1 01Jan2012 03Jan2012 1
02 1 17Mar2014 19Mar2014 1
02 2 17Mar2014 19Mar2014 0
02 3 17Mar2014 19Mar2014 0
03 1 19May2015 25May2015 1
03 2 19May2015 25May2015 0
03 3 19May2015 25May2015 0
03 4 19May2015 25May2015 0
;
run;
'Admissions' is the new variable I have created here (assumption!)
And the challenge is some IDs have episode number up to 10.
Doctor isn't sure what to order 🙂 ? and
For what it's worth, i am posting this
Data Admissions_qtr;
infile cards expandtabs truncover;
input ID $ Epi_number (Start_date Dis_date) (:date9.);
format Start_date Dis_date date9.;
datalines;
01 1 01Jan2012 03Jan2012
02 1 17Mar2014 19Mar2014
02 2 17Mar2014 19Mar2014
02 3 17Mar2014 19Mar2014
03 1 19May2015 25May2015
03 2 19May2015 25May2015
03 3 19May2015 25May2015
03 4 19May2015 25May2015
;
run;
data want;
set Admissions_qtr;
by id Start_date Dis_date;
group_var=first.Dis_date;
run;
SAS Innovate 2025 is scheduled for May 6-9 in Orlando, FL. Sign up to be first to learn about the agenda and registration!
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.
Ready to level-up your skills? Choose your own adventure.