How to select only these rows where values in all column all the same in SAS Enterprise Guide?

I have time in SAS Enterprise Guide like below:

COL1  | COL2
------|--------
12    | 12
15    | 8
10    | 10
...   |....

And I need to select only these rows where values in all column all the same, so as a result I need something like below:

COL1  | COL2
------|--------
12    | 12
10    | 10
...   |....

How can I do that in SAS Enterprise Guide / PROC SQL ?

>Solution :

There are quite a few ways to do it.

   data have;
        input col1 col2;
        datalines;
    1 2
    2 2
    4 5
    6 7
    7 7
    ;
    run;

You can simply use where statement inside proc sql:

proc sql;
    create table want as
        select * 
            from have
            where col1=col2
    ;
quit;

Or you can use if statement using data step:

data want;
    set have;
    if col1 = col2 then output;
run;

Leave a Reply