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 ?

sas-innovate-2024.png

Don't miss out on SAS Innovate - Register now for the FREE Livestream!

Can't make it to Vegas? No problem! Watch our general sessions LIVE or on-demand starting April 17th. Hear from SAS execs, best-selling author Adam Grant, Hot Ones host Sean Evans, top tech journalist Kara Swisher, AI expert Cassie Kozyrkov, and the mind-blowing dance crew iLuminate! Plus, get access to over 20 breakout sessions.

 

Register now!

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