Help using Base SAS procedures

Flagging for ID's that appear under more than 1 indicator

Reply
New Contributor
Posts: 4

Flagging for ID's that appear under more than 1 indicator

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.

Trusted Advisor
Posts: 1,204

Re: Flagging for ID's that appear under more than 1 indicator

proc sql;

select id from have group by id

having count(distinct area_code)>1;

quit;

New Contributor
Posts: 4

Re: Flagging for ID's that appear under more than 1 indicator

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

Super Contributor
Posts: 275

Re: Flagging for ID's that appear under more than 1 indicator

proc sql;

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

quit;

Trusted Advisor
Posts: 1,204

Re: Flagging for ID's that appear under more than 1 indicator

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;

Ask a Question
Discussion stats
  • 4 replies
  • 289 views
  • 4 likes
  • 3 in conversation