07-10-2017 11:55 AM
I would like to list the duplicate observations in 'Found' column. Please advice how. Thanks.
informat name $80.;
input name $ found;
07-10-2017 01:37 PM
Not sure what you're asking. My suggestion was based on the existing order of the records. If you needed it sorted, I'd go with the proc sort nouniquerec option that @Reeza suggested.
Art, CEO, AnalystFinder.com
07-10-2017 02:04 PM
Well, the proc sort code doesn't work in my actual dataset.. Yours works. Basely, I would like to sort the dupicate numbers from zero to largest. I found your code doesn't come with this function. I need to add proc sort on more step. I wish I could do it in one data steps.
by found notsorted;
if not(first.found and last.found);
proc sort data=want; by found; run;
07-10-2017 02:56 PM
Well, the proc sort code doesn't work in my actual dataset..
It's not clear who you're responding to, please quote the original post in your response.
PROC SORT will work for your situation in a single step. If it doesn't you're doing something wrong.
07-10-2017 12:09 PM
NOUNIQUEREC option in PROC SORT does exactly this. You can also use the NOUNIQUEKEY if you're looking at specific variables to identify duplicates.
/*This code demonstrates how to keep only duplicate observations in a data set*/ %*Create sample data set; data have; informat name $80.; input name $ found; cards; If_True 1 If_True_kary 1 If_True_kary 1 If_True_John 3 If_Not 24 If_Not 24 If_Not_Carol 24 If_Not_Carol 24 If_Not_Carol 24 If_False_Joe 288 If_False_Joe 288 ; run; %*Sort with NOUNIQUEREC option; proc sort data=have out=duplicates nouniquerec; by name found; run;
Need further help from the community? Please ask a new question.