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

how to get second highest salary from a employee table and how get a 5th highest salary from a employee table?

11 Answers   ABC, Amex,


data study; input Subj : $3. Group : $1. Dose : $4. Weight : $8. Subgroup; x= input(Weight,5.1); datalines; 001 A Low 220 2 002 A High 90 1 003 B Low 193.6 1 004 B High 165 2 005 A Low 123.4 1 ; Why does X get truncated? X shows up as 22 instead of 220,9 instead of 90 and 19.8 instead of 198? This problem doesnt happen with the values 193.6 and 123.4. This does not happen if x is read on the 5. informat instead of the 5.1 informat

2 Answers  


Why and when do you use proc sql?

0 Answers  


Can we use where and having clauses in a single SAS program. ex: proc sql;     select a,b,c from test      where state in 'KA'      and having <some condition>. Is the above program run correctly, if not why ?     

4 Answers   UHG,


what are input dataset and output dataset options?

6 Answers   HCL,






what is the difference between infile and input? : Sas-administrator

0 Answers  


Explain proc univariate?

0 Answers  


Name validation tools used in SAS

0 Answers  


What is criteria for adverse events and treatment-emergent adverse events?

2 Answers   Accenture,


What is the purpose of the trailing @? The @@? How would you use them?

10 Answers   Accenture,


what is the difference between compiler and interpreter? give any one example (software product) that act as a interpreter?

36 Answers   Accenture, College School Exams Tests, CTS, IBM, IHRD, Infosys, Sylhet Engineering College, TCS, Wipro,


Are you familiar with special input delimiters How are they used?

3 Answers  


Categories