Help using Base SAS procedures

proc sql distinct

Accepted Solution Solved
Reply
Contributor
Posts: 66
Accepted Solution

proc sql distinct

Hi,

I have a transactoin table with transactionid and contactid.

There can be same transactionid for multiple contacts.

I'm trying to figure out how to get the count of unique transactionid AND contactids, but im not sure how to use the 'distinct' function correctly to get it, so far i have:

proc sql;

select

count (distinct transactionid contactid) as unique

from transaction_table

;

quit ;

im getting a syntax error on the count statement.

thanks for your help.


Accepted Solutions
Solution
‎07-28-2011 02:06 PM
Contributor
Posts: 66

proc sql distinct

I figured it out.

proc sql;

select

count (distinct transactionid || contactid) as unique

from transaction_table

;

quit ;

View solution in original post


All Replies
N/A
Posts: 1

proc sql distinct

Posted in reply to Danglytics

proc sql;

select

count (distinct transactionid ) as unique_trans,

count (distinct contactid) as unique_contact

from transaction_table

;

quit ;

Solution
‎07-28-2011 02:06 PM
Contributor
Posts: 66

proc sql distinct

I figured it out.

proc sql;

select

count (distinct transactionid || contactid) as unique

from transaction_table

;

quit ;

🔒 This topic is solved and locked.

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

Discussion stats
  • 2 replies
  • 162 views
  • 0 likes
  • 2 in conversation