BookmarkSubscribeRSS Feed
ccox4682
Calcite | Level 5

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.

4 REPLIES 4
stat_sas
Ammonite | Level 13

proc sql;

select id from have group by id

having count(distinct area_code)>1;

quit;

ccox4682
Calcite | Level 5

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)?

slchen
Lapis Lazuli | Level 10

proc sql;

   select *,case when count(id)>1 then 1 else 0 end as diff_area_flag  from have group by id;

quit;

stat_sas
Ammonite | Level 13

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;

sas-innovate-2024.png

Don't miss out on SAS Innovate - Register now for the FREE Livestream!

Can't make it to Vegas? No problem! Watch our general sessions LIVE or on-demand starting April 17th. Hear from SAS execs, best-selling author Adam Grant, Hot Ones host Sean Evans, top tech journalist Kara Swisher, AI expert Cassie Kozyrkov, and the mind-blowing dance crew iLuminate! Plus, get access to over 20 breakout sessions.

 

Register now!

What is Bayesian Analysis?

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.

Click image to register for webinarClick image to register for webinar

Classroom Training Available!

Select SAS Training centers are offering in-person courses. View upcoming courses for:

View all other training opportunities.

Discussion stats
  • 4 replies
  • 868 views
  • 4 likes
  • 3 in conversation