How to count the frequency of a value by unique ID's

Accepted Solution Solved
Reply
Occasional Contributor
Posts: 7
Accepted Solution

How to count the frequency of a value by unique ID's

All,

 

I am using Medicare data and trying to figure out a way to find the number of unique ids (there are several duplicate bene_ids) with one condition (back_pn_office_visit=1).  The following code for unique bene_ids works, but I can't figure out how to add the condition.  Any ideas?  Thank you! 

 

proc sql;
select count (distinct bene_id) as in 'n_id' from back_analysis_2013A;
quit;

 

where does 'back_pn_office_visit=1' go?

 

Monica

 

Monica



 


Accepted Solutions
Solution
‎03-24-2017 09:31 PM
PROC Star
Posts: 7,433

Re: How to count the frequency of a value by unique ID's

Some of your syntax is off. I think you want something like:

 

proc sql;
  select count (distinct sex) as n_id
    from sashelp.class
      where age gt 12
  ;
quit;
 

Art, CEO, AnalystFinder.com

View solution in original post


All Replies
Solution
‎03-24-2017 09:31 PM
PROC Star
Posts: 7,433

Re: How to count the frequency of a value by unique ID's

Some of your syntax is off. I think you want something like:

 

proc sql;
  select count (distinct sex) as n_id
    from sashelp.class
      where age gt 12
  ;
quit;
 

Art, CEO, AnalystFinder.com

☑ This topic is solved.

Need further help from the community? Please ask a new question.

Discussion stats
  • 1 reply
  • 133 views
  • 0 likes
  • 2 in conversation