SAS : Eliminate duplicates if a condition is satisfied -


I want to eliminate the duplicate from the database based on an identifier, one order and one condition.

More accurate, I have data with many comments. I sometimes have a condition that I want to keep that observation anyway (to fix it condition = 1 ), but keep an observation with the same identifier even if it does not Be ( condition = 0 ).

But if I have many observations for an identifier, where condition = 0 then I want to end the duplicates, together with the highest criteria order .

I can do this without condition

  proc sort data =; Identifier descending order; Run; Proc sud nudopkey data = is; By identifier; Run;  

But how should my position be included in it?

Edit 1: Add a database example:

  data test; Input identifier $ order status; Datalines; 1023 1 0 1023 2 0 1064 2 0 1064 1 0 10 9 1 1 10 9 1 1;  

Then I

  • 1023 2
  • keep 1064 2 0
  • 1098 1 0 >
  • 10 9 1 1

Edit 2: Tried to make my conditions accurate

I think that you want to end duplicates, when the condition for all the records for the identifier is set to 0. In that case you want to keep the record with the maximum order and end all other records with the same identifier.

  Proc sql; To create a table * maximum (status) by the identifier from the test group having 0 or order eq maximum (order); Skip;  

This keeps all the rows for an identifier where maximum position = 1 or in those cases where maximum position = 0, select the row with the maximum order.

What do you want?


Comments

Popular posts from this blog

java - Can't add JTree to JPanel of a JInternalFrame -

javascript - data.match(var) not working it seems -

javascript - How can I pause a jQuery .each() loop, while waiting for user input? -