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 example
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 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
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
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 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 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 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