how do we get duplicate observations in a separate dataset?
Answers were Sorted based on User's Feedback
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 |
Answer / mallikarjuna reddy.vanna
use DUPOUT option in proc sort statement.
Is This Answer Correct ? | 12 Yes | 1 No |
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 |
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 |
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 |
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 |
how to get second highest salary from a employee table and how get a 5th highest salary from a employee table?
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
Why and when do you use proc sql?
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 ?
what are input dataset and output dataset options?
what is the difference between infile and input? : Sas-administrator
Explain proc univariate?
Name validation tools used in SAS
What is criteria for adverse events and treatment-emergent adverse events?
What is the purpose of the trailing @? The @@? How would you use them?
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?