03-13-2014 11:46 AM
I have a list of hospital where chart number is the patient identifier and account number is the unique identifier for the visit. I would like to create a data set of just the first visit for the chart number and the last visit for the chart number.
input @1 chartno $6.
@7 acctno $3.
@10 admdate yymmdd8.
@18 sepdate yymmdd8.
@26 postal $6.
format admdate yymmdd10. sepdate yymmdd10.;
For the above for chartno 111111 I want the data set to only include the March 31, 2012 visit and the November 30, 2012 visit. Any assistance greatly appreciated.
03-13-2014 12:07 PM
Not sure if I'm missing the problem here. Sort by chartno and date, set with by statement and use first. and last. variables:
proc sort data = have;
03-13-2014 12:11 PM
create table want as
select chartno, min( admdate) as FirstVisit format=yymmdd10., max(admdate) as LastVisit format=yymmdd10.
group by chartno;
03-14-2014 10:52 AM
Thank you so much for all the really great answers. I chose Reeza's only because simple is best! I knew when I posted it the answer would be simple but I could not get the correct syntax. Thanks again.
Need further help from the community? Please ask a new question.