how do we get duplicate observations in a separate dataset?

Answers were Sorted based on User's Feedback



how do we get duplicate observations in a separate dataset?..

Answer / bitla

ex:

data dup1 dup2;
set original;
by dup_var;
if first.dup_var then output dup1 else output dup2;
run;

Is This Answer Correct ?    11 Yes 0 No

how do we get duplicate observations in a separate dataset?..

Answer / mallikarjuna reddy.vanna

use DUPOUT option in proc sort statement.

Is This Answer Correct ?    12 Yes 1 No

how do we get duplicate observations in a separate dataset?..

Answer / natrajboga

use the dupout= and nodupkey options in proc sort and
followed by BY statemet with list of vars

proc sort data=xxx dupout=dup_xxx nodupkey;
by var1;
run;

/* see the log window */

proc print data=dup_xxx;
run;

Is This Answer Correct ?    8 Yes 0 No

how do we get duplicate observations in a separate dataset?..

Answer / vipin choudhary

Proc sort data = indata;
by name;
run;
Data outdata;
set indata;
by name;
if first.name and last.name then delete;
run;
proc print data = outdata;
run;

or else you can use the dupout option in proc sort

Is This Answer Correct ?    4 Yes 2 No

how do we get duplicate observations in a separate dataset?..

Answer / rajaanku11

First sort them in descending order and then using first.var
separate all the first observations into a new dataset and
the remaining into another. So unique observations from each
group
will come into one dataset and the other duplicate
observations will enter into another dataset.

Is This Answer Correct ?    2 Yes 1 No

how do we get duplicate observations in a separate dataset?..

Answer / rajaanku11

proc sql;
create table dup_obs as (
select * from <lib>.<dsn>
group by <dup var>,<list of other vars>
having count(*)>1 )
quit;

Is This Answer Correct ?    4 Yes 3 No

Post New Answer

More SAS Interview Questions

what is sas? is a package or tool? give me introduction about sas?

11 Answers   Accenture,


hi i date is 05sep2005; i want the oupput like 05sep2005:00:00:00 ; how it wil come?

6 Answers   Accenture,


explain the use of % includes a statement in sas? : Sas-administrator

0 Answers  


what can you learn from the sas log when debugging? : Sas programming

0 Answers  


Diff between proc sql merge and join?

1 Answers   HSBC, Sristek,


i have multiple .csv files in a unix directory. every file is having variable names as header.even for empty file also. suppose take 3 files a.csv b.csv c.csv a.csv contains data as name;age,salary; raja;34;4000; ravi;33;5000; kumar;25;3000; b.csv contains data as name;age,salary; ajay;40;4500; and c.csv contains name;age,salary; (only headers) Now i want to import and append all these files in to a single dataset. i tried infile statement with *.csv to import all at a time. but i m not getting correct data. please help me . its urgent. thank you in advance

2 Answers   Tech Mahindra,


What is by-group processing?

0 Answers  


what is AE onset date and what is RDS?

4 Answers   Accenture,


In SAS how to read the variable values having different formats. eg:mar99,mar1999 (in a single variable)

8 Answers   GSK GlaxoSmithKline,


what is difference in window SAS & Unix SAS.....how do define working environment in both???

1 Answers   JPMorgan Chase,


Have you ever used the SAS Debugger?

0 Answers   Quintiles,


how does sas handle missing values in: assignment statements, functions, a merge, an update, sort order, formats, procs? : Sas programming

0 Answers  


Categories