Ashutosh, let me show what SAS can do then we'll discuss what it can't.
The DROP= data set option and DROP statement support variable lists to drop a set of variables. For instance, to drop all the variables from an output data set that begin with the prefix "X" one would code:
DATA OUT( DROP=X: );
To drop the variables X1 through X10, one would code:
DATA OUT( DROP=X1-X10 );
Variable lists work in many situations where a programmer would like to drop an array of variables.
The situation where variable lists break down is when an array of variables do not have a common prefix. As in:
X Y Z;
In this case using DROP=X--Z may drop X, Y, and Z. I say may because if the variables aren't ordering in the PDV as X, then Y, then Z, the variables you think you're dropping will not be dropped. I'd rather code DROP=X Y Z than use X--Z because maintaining a variable ordering in the PDV can be tricky and obfuscate the code.
If you have a situation where variable lists don't work well, a workaround is to place the array variables in a macro variable. As in this code:
%let ArrayVars = x y z;
This program will create an array consisting of the variables X, Y, and Z and will drop them from the output data set.
The reason arrays aren't supported with the DROP= or KEEP= option is that the options are not processed by the DATA step. Rather, they are processed by the engine that is used to read or write the data set. The engine is aware of the variables to be read or written, so it can drop or keep them. The engine is not aware of DATA step arrays, so it would not recognize a name as an array. The separation between the DATA step and the engine is what keeps DROP= or KEEP= from handling arrays.
I have just started with a system that has many, many fields - Ashutosh you might be in the same boat. Correct me if I'm wrong here.
We don't have a situation of X Y Z but rather 100's of fields, which makes programs lengthy and difficult to manage. Arrays make short work of repeated calculations and macro variables containing the variable names also shortcut a lot of it. But whatever route you take, you still end up with these long, unwieldy lists somewhere.
I'm taking the attitude of more rows less columns - trying the reduce the variable lists to categories in columns. Use of proc transpose can interchange between the tables. Taking this different approach makes programming much easier and shorter - have you tried thinking in this way? I've also returned a 75% space saving with this method - this is the business motivation of taking this route. Its often difficult justifying code changes without any obvious end-result.
Data organization should be given critical thought when designing a solution. The way data are arranged will affect the complexity of the implementation and performance.
Views provide a mechanism for rearranging data without replicating them on disk. When different applications rely on the same data, yet each implementation would prefer a different layout, views often provide a sufficient solution.