I've the table as shown below. If I ignore the 'Serial_Num' field then there are few duplicate records. Now I want to identify the 'Serial_Num' of those duplicate records. Any help to achieve this using SQL?
You can use group by and having clause in proc sql.
proc sql; create table output_table as select * from input_table group by Name, Age, Salary, Gender having count(*)>=2; quit; proc print data=output_table; run;
Yes, I have executed the query in Snowflake.
I believe that we will get the similar error if we execute the similar
query in SAS.
No, you won't. You'll get a NOTE about the automatic remerge, which is the purpose of the suggested code.
create table output_table as select t1.* from input_table as t1 inner join ( select Name, Age, Salary, Gender from input_table group by Name, Age, Salary, Gender having count(*) >= 2 ) as t2 on t1.name = t2.name and t1.age = t2.age and t1.salary = t2.salary and t1.gender = t2.gender
Learn how use the CAT functions in SAS to join values from multiple variables into a single value.
Find more tutorials on the SAS Users YouTube channel.