Keep Drop statements in SAS – keep column name like; Drop Column name like SAS

Select or Keep columns in SAS tables is achieved by using KEEP statement. DROP Statement is used to drop columns in SAS. Let’s see an example on how to drop single columns, drop multiple columns in SAS. How to select or keep multiple columns in SAS. KEEP and DROP in SAS datastep. Select column names like in SAS. Drop column names like in SAS.

  • Keep Statement in SAS – select column in SAS
  • Keep statement like in SAS – Select columns like in SAS
  • Drop Statement in SAS – Drop single column in SAS
  • Drop Statement in SAS – Drop multiple column in SAS
  • Drop Statement in SAS – Drop columns like in SAS
  • Keep or drop below set statement in SAS
  • Keep or drop while printing in SAS.

So we will be using EMP_DET Table in our exampleKeep Drop statements in SAS - keep column name like ; Drop Column name like SAS 1

 

 

Simple Keep Statement in SAS – Keep in SAS

Select or Keep columns in SAS tables is achieved by using KEEP statements. We will be selecting or keeping two columns as shown below


/* keep */  

data emp_det1 (keep= Employee salary_2020); 
set emp_det; 
run; 

So the resultant table will be
Keep Drop statements in SAS - keep column name like ; Drop Column name like SAS 2

 

 

 Keep Column name like – Keep like in SAS

Select or Keep columns in SAS tables is achieved by using KEEP statements. We will be selecting or keeping the columns which is salary_:

/* keep name like */ 

data emp_det1(keep= Employee salary_:); 
set emp_det; 
run; 

So the resultant table will be
Keep Drop statements in SAS - keep column name like ; Drop Column name like SAS 3

 

 

Simple Drop Statement in SAS – Drop in SAS

Drop columns in SAS tables are achieved by using DROP statements. We will be dropping a column as shown below


/* drop */ 

data emp_det1(drop=salary_2020); 
set emp_det; 
run;

So the resultant table will be
Keep Drop statements in SAS - keep column name like ; Drop Column name like SAS 4

 

 

 Drop Column name like – Drop like in SAS

Drop columns in SAS tables are achieved by using DROP statements. We will be dropping all the columns like salary_:

/* Drop name like */ 

data emp_det1 (drop=salary_:); 
set emp_det; 
run;
 

So the resultant table will be
Keep Drop statements in SAS - keep column name like ; Drop Column name like SAS 5

 

 

Keep Drop Options : Keep or Drop below set statement

Drop or Keep columns in SAS tables is achieved by using DROP or KEEP statements below datastep as shown below

/* keep drop option : keep or drop below set statement */ 
 
data emp_det1; 
set emp_det; 
drop salary_2020; 
run;

Keep Drop statements in SAS - keep column name like ; Drop Column name like SAS 6

 

 

Keep Drop Options : Keep or Drop variable while printing

Drop or Keep columns in SAS tables is achieved by using DROP or KEEP statements along with the data statement as shown below

/* keep drop option : keep or drop variable while printing */ 
 
data emp_det1 (drop= salary_2020); 
set emp_det; 
run;

So the resultant table which drops the salary_2020 column by giving drop statement along with data statement
Keep Drop statements in SAS - keep column name like ; Drop Column name like SAS 6

 

 

Keep Drop Options : Keep or Drop variable with set statement

Drop or Keep columns in SAS tables is achieved by using DROP or KEEP statements along with the set  statement as shown below


/* keep drop option : keep or drop variable with set statement */ 
 
data emp_det1; 
set emp_det (drop= salary_2020); 
run; 

So the resultant table which drops the salary_2020 column by giving drop statement along with set statement

Keep Drop statements in SAS - keep column name like ; Drop Column name like SAS 8