Row bind in SAS

Row bind in SAS is accomplished in two ways, one way by specifying the tables together in SET statement and other way by using UNION ALL in SAS PROC SQL.  Lets see an example on row bind in SAS.

  • Row Bind in SAS – using Datastep
  • Row bind in SAS – using UNION ALL in PROC SQL

ROW BIND EXAMPLE:
Row bind in SAS 0a

 

We will be using EMP_DET1 and EMP_DET2 table

EMP_DET1:
Row bind in SAS 1

 

EMP_DET2:
Row bind in SAS 2

 

Row Bind in SAS : Method 1

In this method we will use datastep procedures to row bind two tables. SET statement takes two tables namely EMP_DET1 and EMP_DET2 and binds them together and named as EMP_DET_FIN as shown below


/* Method 1 row bind */ 

data EMP_DET_FIN; 
SET EMP_DET1 EMP_DET2; 
run;

So the resultant row binded table in SAS will be
Row bind in SAS 3

 

 

Row Bind in SAS : PROC SQL using UNION ALL : Method 2

In this method we will use PROC SQL  with UNION ALL to row bind two tables. UNION ALL  statement takes two tables namely EMP_DET1 and EMP_DET2 and binds them together and named as EMP_DET_FIN as shown below


PROC SQL; 
create table EMP_DET_FIN AS 
( 
select * from EMP_DET1 
union all 
select * from EMP_DET2 
); 
QUIT;

So the resultant row binded table will be
Row bind in SAS 4