DATA Step, Macro, Functions and more

distinct on selected variables and remaining as it is

Accepted Solution Solved
Reply
Contributor
Posts: 41
Accepted Solution

distinct on selected variables and remaining as it is

is there any way in proc sql if i can select distinct on few varibles and have remaining as it is.

as below i do not want distinct on b.term,b.acce and need for the rest

proc sql;
create table _values_ as
select (distinct b.table,b.column,b.origin,b.originwhere,b.algorithm), b.term,b.acce
from vcol a right join source_columns b
on a.origin=b.origin

quit;

 

any suggestion please


Accepted Solutions
Solution
‎03-29-2017 07:17 AM
Super User
Posts: 7,766

Re: distinct on selected variables and remaining as it is

Posted in reply to alexdsa310

As soon as the distinct does not extend over all columns, it becomes meaningless, as all rows from the dataset will be included anyway. Play around with the concept for a while, and you'll see what I mean.

 

---------------------------------------------------------------------------------------------
Maxims of Maximally Efficient SAS Programmers

View solution in original post


All Replies
Super User
Posts: 7,766

Re: distinct on selected variables and remaining as it is

Posted in reply to alexdsa310

How about

proc sql;
create table _values_ as
select b.table,b.column,b.origin,b.originwhere,b.algorithm, b.term,b.acce
from vcol a right join source_columns b
on a.origin=b.origin
group by b.table,b.column,b.origin,b.originwhere,b.algorithm
;
quit;

?

---------------------------------------------------------------------------------------------
Maxims of Maximally Efficient SAS Programmers
Contributor
Posts: 41

Re: distinct on selected variables and remaining as it is

Posted in reply to KurtBremser

No need to mention distinct? sorry to ask

Solution
‎03-29-2017 07:17 AM
Super User
Posts: 7,766

Re: distinct on selected variables and remaining as it is

Posted in reply to alexdsa310

As soon as the distinct does not extend over all columns, it becomes meaningless, as all rows from the dataset will be included anyway. Play around with the concept for a while, and you'll see what I mean.

 

---------------------------------------------------------------------------------------------
Maxims of Maximally Efficient SAS Programmers
☑ This topic is solved.

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

Discussion stats
  • 3 replies
  • 108 views
  • 0 likes
  • 2 in conversation