BookmarkSubscribeRSS Feed
learn_SAS_23
Quartz | Level 8

Hi Team, 

 

am looking for a solution for the situation like this 

 

data have;
infile cards dlm=",";
input
Patient_ID : 8.
Admit_Date : anydtdtm.
Disch_Date : anydtdtm.
Facility_Type : $32.
;
format admit_date disch_date datetime19.;
cards;
12345,02JAN2014:00:00:00.000,05JAN2014:00:00:00.000,Nursing Home  
12345,02JAN2014:00:00:00.000,07JAN2014:00:00:00.000,Hospital

23456,02JAN2014:00:00:00.000,06JAN2014:00:00:00.000,Nursing Home
23456,02JAN2014:00:00:00.000,06JAN2014:00:00:00.000,,Nursing Home



Desitred output : 

i need to print below data set in a HTML page , mismatched records for ex : Patient_ID=12345 have different records in two the columns, I need to high light the column which is having mismatch , either bold or colored.

 

12345,02JAN2014:00:00:00.000,05JAN2014:00:00:00.000,Nursing Home  
12345,02JAN2014:00:00:00.000,07JAN2014:00:00:00.000,Hospital
23456,02JAN2014:00:00:00.000,06JAN2014:00:00:00.000,Nursing Home
23456,02JAN2014:00:00:00.000,06JAN2014:00:00:00.000,,Nursing Home

 

Can i achieve this through sas 

 

1 REPLY 1
Kurt_Bremser
Super User
data have;
infile cards dlm=",";
input
Patient_ID : 8.
Admit_Date : anydtdtm.
Disch_Date : anydtdtm.
Facility_Type : $32.
;
format admit_date disch_date datetime19.;
cards;
12345,02JAN2014:00:00:00.000,05JAN2014:00:00:00.000,Nursing Home  
12345,02JAN2014:00:00:00.000,07JAN2014:00:00:00.000,Hospital
23456,02JAN2014:00:00:00.000,06JAN2014:00:00:00.000,Nursing Home
23456,02JAN2014:00:00:00.000,06JAN2014:00:00:00.000,Nursing Home
;
run;

data flagged (keep=Patient_ID Admit_Date);
set have;
by Patient_ID Admit_Date;
dis_date_old = lag(Disch_Date);
fac_old = lag(Facility_Type);
if
  not first.Admit_Date and (
    Disch_Date ne dis_date_old or Facility_Type ne fac_old
  )
then output;
run;

data want;
merge
  have (in=a)
  flagged (in=b)
;
if a;
flag = b;
run;

You can now use flag in a proc report compute block to change the format(s) of a displayed line.

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!
SAS Enterprise Guide vs. SAS Studio

What’s the difference between SAS Enterprise Guide and SAS Studio? How are they similar? Just ask SAS’ Danny Modlin.

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
  • 1 reply
  • 600 views
  • 0 likes
  • 2 in conversation