How would you delete duplicate observations?
Answers were Sorted based on User's Feedback
Answer / poornima
we can delete duplicate observations by using nodup or
nodupkey option in the proc sort
Example :-
Proc sort data=datasetname nodup;
run;
Is This Answer Correct ? | 33 Yes | 12 No |
Answer / padmasri
In 3 ways we can delete the duplicate records.
1.procedure proc sort
in proc sort there are two ways to delete duplicate
observations:
* nodupkey
*noduprec
2.first. and last.
3.proc sql
these 3 ways we can delet the duplicate records in sas.
Is This Answer Correct ? | 16 Yes | 0 No |
Answer / srinivas
there 3 options to delete duplicate obs
1. nodup
2. nodupkey
3.noduprec
if a entire record is duplicated in sense we use nodup of
nodup rec in proc sort procedure.
proc sort data=dsn nodup/noduprec;
by var;
run;
if a variable is repeated not a entire record . this time
we use nodupkey
proc sort data=dsn nodupkey;
by var;
run;
ex; in a dataset empid is repeated then use this syn. and
the empid is used in by var statement.
Is This Answer Correct ? | 19 Yes | 5 No |
Answer / vijay
There are several ways to do this. However the easliest
code-wise is to use PROC SORT. For example:
PROC SORT DATA=mydata NODUPKEY;
BY variable;
RUN;
Is This Answer Correct ? | 17 Yes | 7 No |
There are two ways of deleting the records from the dataset
with the help of PROC SORT.
1. Using NODUP/NODUPRECS
2. Using NODUPKEY
The first option deletes the records only if all the
variables values are repeated in the subsequent records.
The second options deletes the records only if the value of
the BY variables given in the BY clause are repeated in the
subsequent records.
Is This Answer Correct ? | 4 Yes | 1 No |
What are the Aggregate functions in SQL ?
How to create list output for cross-tabulations in proc freq?
How to create an external dataset with sas code?
how to intersect the tables by using PROC MIXED?
How would you code a merge that will write the matches of both to one data set, the non-matches from the left-most data set to a second data set, and the non-matches of the right-most data set to a third data set?
What is Linear Regression?
Name types of category in which SAS Informats are placed?
How to get the repeated values by using sql in sas ?
If reading a variable length file with fixed input, how would you prevent SAS from reading the next record if the last variable didn’t have a value?
How substr function works in sas?
If you have a dataset that contains 100 variables, but you need only five of those, what is the code to force SAS to use only those variables?
In SAS how to read the variable values having different formats. eg:mar99,mar1999 (in a single variable)
8 Answers GSK GlaxoSmithKline,