There are duplicate identifiers in my dataset. Regardless, each has a different area code. I need to flag where the same id appears under a different area code. I'm sure there's a straightforward solution, just not sure what it is. Can anyone help? Thanks in advance.
proc sql;
select id from have group by id
having count(distinct area_code)>1;
quit;
Thank you, I figured it would be a proc sql. But, where can I insert a command for a separate column (e.g., diff_area_code_flag = 1)?
proc sql;
select *,case when count(id)>1 then 1 else 0 end as diff_area_flag from have group by id;
quit;
proc sql;
select *,case when count(distinct area_code)>1 then 1 else 0 end as diff_area_code_flag
from have
group by id;
quit;
Join us for SAS Innovate April 16-19 at the Aria in Las Vegas. Bring the team and save big with our group pricing for a limited time only.
Pre-conference courses and tutorials are filling up fast and are always a sellout. Register today to reserve your seat.
Learn the difference between classical and Bayesian statistical approaches and see a few PROC examples to perform Bayesian analysis in this video.
Find more tutorials on the SAS Users YouTube channel.