3

How do i write in sas:

proc sql; 
create table THIS as 
        select * 
        from MAIN(keep=id col1 -- col34)
    where (AT LEAST ONE OF THE COLUMNS contains 1) ;
    ; 

I am having a problem figuring out how to write that last line bc I want to keep all columns so I am not just checking one column i want to check for all of them.

DomPazz
  • 12,415
  • 17
  • 23
Jessica Warren
  • 378
  • 1
  • 4
  • 15

2 Answers2

5

You will have more flexibility if you use a DATA step instead of PROC SQL since you cannot use variable lists in PROC SQL code.

Assuming all of the variables in your list are numeric you could do something like this.

data this;
   set main ;
   keep id col1 -- col34;
   if whichn(1,of col1 -- col34);
run;
Tom
  • 47,574
  • 2
  • 16
  • 29
4

Tom is right, the best approach is with a data step. If you are certain you want to do it with SQL though you could do something like this:

proc sql noprint;
  create table THIS as
  select * 
  from MAIN(keep=id col1 -- col34)
  where sum(col1,col2,col3, ... ,col34)
  ;
quit;
Robert Penridge
  • 8,424
  • 2
  • 34
  • 55