Drop Multiple Variables of similar name in SAS



In a dataset I am working on, I have variable names like Var1, Var2, Var3, Var4 ……. Var74. I want to drop the variables Var32 to Var72. Do I need to take each variable name in Drop command? or is there any another option to perform this in data step. Please help…




Look at the below scenario, here i have created a data set having Month, X1, X2, X3,…X6 as variables.

Data Ytd;
Input Month$ X1 X2 X3 X4 X5 X6;
Jan 1	2	3	4	5	6
Feb 7	8	9	10	11	12
Mar 13	14	15	16	17	18

Let’s say, i want to drop variable X2, X3, X4 and X5, This can be achieved by using below statements:

Data Check (Drop= X2-X5);
Set Ytd;

Above I have used Drop=X2 - X5, it works because x1-x5 are numerically consecutive. Now assume variables are not numerically consecutive and we want to delete variables, which are together. Like I want to drop varibale Month, X1, X2 and X3.

Data Check (Drop= Month--X3);
Set Ytd;

Above I have used Drop=Month – X3, it works because Month – x3 are physically in order on the data set.