BookmarkSubscribeRSS Feed
🔒 This topic is solved and locked. Need further help from the community? Please sign in and ask a new question.
sks521
Quartz | Level 8

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;
1 ACCEPTED SOLUTION

Accepted Solutions
novinosrin
Tourmaline | Level 20

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;

View solution in original post

6 REPLIES 6
sks521
Quartz | Level 8

Just to say, there are 77650 rows in my data set

novinosrin
Tourmaline | Level 20

Not sure, how to imagine your expected output and guess. Can you post the expected sample too plz for the posted input

sks521
Quartz | Level 8

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;
sks521
Quartz | Level 8

'Admissions' is the new variable I have created here (assumption!)

sks521
Quartz | Level 8

And the challenge is some IDs have episode number up to 10.

novinosrin
Tourmaline | Level 20

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;

Ready to join fellow brilliant minds for the SAS Hackathon?

Build your skills. Make connections. Enjoy creative freedom. Maybe change the world. Registration is now open through August 30th. Visit the SAS Hackathon homepage.

Register today!
How to Concatenate Values

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.

Click image to register for webinarClick image to register for webinar

Classroom Training Available!

Select SAS Training centers are offering in-person courses. View upcoming courses for:

View all other training opportunities.

Discussion stats
  • 6 replies
  • 628 views
  • 0 likes
  • 2 in conversation