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

Hi I have a customer linking dataset and i have five attibutes by below example: 

APPLICATION_NUM LINK_CUSTOMER_ID TEMP_CUSTOMER_ID LINKED_CUSTOMER_ID LINK_TYPE
11661523 9086964 9572284 6543652 160
11661523 9086964 9572284 9572284 190
11661523 9572284 9572284 6543652 160

 

what is want to do is to identify records with same application_num and link_customer_id and when they are same, i want to output only the record when the temp_customer_id is equal to linked_customer_id. 

 

that is for this example: i would need the output to be as below. 

APPLICATION_NUM LINK_CUSTOMER_ID TEMP_CUSTOMER_ID LINKED_CUSTOMER_ID LINK_TYPE
11661523 9086964 9572284 9572284 190
11661523 9572284 9572284 6543652 160

1 ACCEPTED SOLUTION

Accepted Solutions
ChrisNZ
Tourmaline | Level 20

@Jagadeesh2907   

You know you need to provide the data as a data step (that you have run and vetted *from the code pasted*).

Please do so.

This should give you a starting point:

data HAVE;
input APPLICATION_NUM LINK_CUSTOMER_ID TEMP_CUSTOMER_ID LINKED_CUSTOMER_ID LINK_TYPE ;
cards;
11661523 9086964 9572284 6543652 160
11661523 9086964 9572284 9572284 190
11661523 9572284 9572284 6543652 160
;
proc sql;
  select *
        , TEMP_CUSTOMER_ID=LINKED_CUSTOMER_ID  as FLAG
        , count(*)                             as DUP
  from HAVE
  group by APPLICATION_NUM, LINK_CUSTOMER_ID  
  having DUP=1 | FLAG=1;
APPLICATION_NUM LINK_CUSTOMER_ID TEMP_CUSTOMER_ID LINKED_CUSTOMER_ID LINK_TYPE FLAG DUP
11661523 9086964 9572284 9572284 190 1 2
11661523 9572284 9572284 6543652 160 0 1

 

View solution in original post

2 REPLIES 2
ChrisNZ
Tourmaline | Level 20

@Jagadeesh2907   

You know you need to provide the data as a data step (that you have run and vetted *from the code pasted*).

Please do so.

This should give you a starting point:

data HAVE;
input APPLICATION_NUM LINK_CUSTOMER_ID TEMP_CUSTOMER_ID LINKED_CUSTOMER_ID LINK_TYPE ;
cards;
11661523 9086964 9572284 6543652 160
11661523 9086964 9572284 9572284 190
11661523 9572284 9572284 6543652 160
;
proc sql;
  select *
        , TEMP_CUSTOMER_ID=LINKED_CUSTOMER_ID  as FLAG
        , count(*)                             as DUP
  from HAVE
  group by APPLICATION_NUM, LINK_CUSTOMER_ID  
  having DUP=1 | FLAG=1;
APPLICATION_NUM LINK_CUSTOMER_ID TEMP_CUSTOMER_ID LINKED_CUSTOMER_ID LINK_TYPE FLAG DUP
11661523 9086964 9572284 9572284 190 1 2
11661523 9572284 9572284 6543652 160 0 1

 

Jagadeesh2907
Obsidian | Level 7
Thank you Chris.I will refer to your high performance SAS coding reference. Thank you for guiding me.

SAS Innovate 2025: Call for Content

Are you ready for the spotlight? We're accepting content ideas for SAS Innovate 2025 to be held May 6-9 in Orlando, FL. The call is open until September 16. Read more here about why you should contribute and what is in it for you!

Submit your idea!

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
  • 2 replies
  • 1333 views
  • 1 like
  • 2 in conversation