BookmarkSubscribeRSS Feed
deleted_user
Not applicable
For example:

Subscriber_Objid Account_ID Contact_Objid Contact_ID
1. 268435459 55 268435457 56
2. 268435459 NULL 268435457 NULL

The second row should be removed.

OR

Subscriber_Objid Account_ID Contact_Objid Contact_ID
1. 268435459 55 268435457 56
2. 268435459 56 268435457 NULL

The second row should NOT be removed. because Account_id is not same for both rows.

what i have to do ?

1. i have to compare two rows of data set having same Contact_Objid(not nullable column).
2. if both rows I and J having same Contact_Objid then i have to delete I th row from data set if all other columns of i th rows are having either same value of j th row or Null value.

please give me idea.....how can i implement .....i am thinking about lag function.

is it possible complete all process in one data step...?


thanks
4 REPLIES 4
saroj
Calcite | Level 5
does the jth row follow the ith row or could the ith row and the jth row be any rows in the input file.
deleted_user
Not applicable
thanks for giving time..
here j = i+1;

comparison between jth and i th row will take place . and one will be deleted. if i th row is subset of jth row then ith will be deleted. else vise versa.
deleted_user
Not applicable
assuming you want just the last of equal groups of contact_objid and account_id, you could use by group processing (even if you need to add the notsorted option)
[pre]data new_data ;
do until( last.contact_objid ) ;
set original ;
by account_id notsorted contact_objid notsorted ;
end ;
run ;[/pre]However, this method depends on having actual Account_id rather than NULL.

good luck

PeterC
saroj
Calcite | Level 5
how about using two input statements in the datastep to read two rows per iteration and output and not output based on comparison output ?

hackathon24-white-horiz.png

The 2025 SAS Hackathon Kicks Off on June 11!

Watch the live Hackathon Kickoff to get all the essential information about the SAS Hackathon—including how to join, how to participate, and expert tips for success.

YouTube LinkedIn

Creating Custom Steps in SAS Studio

Check out this tutorial series to learn how to build your own steps in SAS Studio.

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
  • 4 replies
  • 1691 views
  • 0 likes
  • 2 in conversation