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

hackathon24-white-horiz.png

2025 SAS Hackathon: There is still time!

Good news: We've extended SAS Hackathon registration until Sept. 12, so you still have time to be part of our biggest event yet – our five-year anniversary!

Register Now

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.

SAS Training: Just a Click Away

 Ready to level-up your skills? Choose your own adventure.

Browse our catalog!

Discussion stats
  • 1 reply
  • 1014 views
  • 0 likes
  • 2 in conversation