BookmarkSubscribeRSS Feed
sasg
Calcite | Level 5

Hi all,

I have a data like this


site  pt   visitname  visit_dt     visit1    visit1_dt      flag
1101  11011001  visit1     2017-12-22                             data in crf not in vendor
1101  11011001                          visit1      2017-12-22      data in vendor not in CRF

1104  11041002  visit4     2017-07-07               data in crf not in vendor 
1104  11041002         Unscheduled     2017-07-07      data in vendor not in CRF   
 
9910  99011002 visit5    2018-02-01     data in crf not in vendor 


I want ouput to be like this:

site  pt   visitname  visit_dt     visit1    visit1_dt      flag
1101  11011001  visit1     2017-12-22                             date mismatch
1101  11011001                          visit1      2017-12-21      date mismatch

1104  11041002  visit4     2017-07-07               visit mismatch
1104  11041002         Unscheduled     2017-07-07      visit mismatch  
 
9910  99011002 visit5    2018-02-01     data in crf not in vendor 


need to check all the rows in a dataset to see site,pt and visit  is same then need to create the 'date mismatch' flag.same for visit.
I'm using below code but it is flagging only one record instead of 2 records,let me know how can i fix this issue.   


data final2;
 MERGE final1 (firstobs=1)
          final1 (firstobs=2 rename=(site = st
                                     pt=pt2
                                     visitname=visitname1
            visit_dt=visit_dt1
         visit1_dt=visit1_dt1
         visit1=visit1_1
         flag=flag_1));
   if    site = st
   and  pt = pt2
   and visitname = visit1_1
   and visitname1 = visit1
   and flag_1 ne flag  then Flag2 = "Date Mismatch";
   else  flag2 = " ";

/*  drop st pt2 visitname1 visit_dt1 visit1_dt1 visit1_1 flag_1;*/

run; 

Can you please guide me how to fix this issue.

Thank you so much.  

1 REPLY 1
reddy19
Calcite | Level 5

Can someone suggest some idea on this issue

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