Follow

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use
Contact

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 ?

MEDevel.com: Open-source for Healthcare and Education

Collecting and validating open-source software for healthcare, education, enterprise, development, medical imaging, medical records, and digital pathology.

Visit Medevel

>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;
Add a comment

Leave a Reply

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use

Discover more from Dev solutions

Subscribe now to keep reading and get access to the full archive.

Continue reading