Edit

SAS: PROC SQL (Where)

2016/12/18
  If you create a new table with extracting from a source table, you can use 'When clause'.  The manner of the grammar for 'When' clause on 'Proc SQL' is similar (same as?) to 'Where statement on Data Step.'  The following sample programs show how to create a new table of 'D_FEMALE' extracting only 'FEMALE' subjects from 'DEMOG' table (LINK).  The sample SQL program has three different 'where clause,' first standard where clause, second including in function, third 'contains function (?),' creating same table.  One note is that Contains' can only use for a 'Character' variable.


PROGRAM 
-------------------------------------- 
*************************************
WHERE CLAUSE: EXTRACT SEX='FEMALE'
*************************************;
PROC SQL ;
  CREATE TABLE D_FEMALE AS SELECT *
  FROM DEMOG
  WHERE SEX='FEMALE' ;
QUIT ;

PROC SQL ;
  CREATE TABLE D_FEMALE AS SELECT *
  FROM DEMOG
  WHERE SEX IN ('FEMALE') ;
QUIT ;

PROC SQL ;
  CREATE TABLE D_FEMALE AS SELECT *
  FROM DEMOG
  WHERE SEX CONTAINS 'FEMALE' ;/*ONLY FOR CHARACTER.*/
QUIT ;

--------------------------------------  

OUTPUT (NOT FULL DATA)  


Search This Blog