The provided examples illustrate the use of the DROP statement with internal variables or implicit file specifications.
1 Code Block
DATA Step
Explanation : This example shows how to explicitly list the variables 'time', 'shift', and 'batchnum' to exclude them from output SAS data sets. These variables will be used during the DATA step but will not appear in the final data set.
Copied!
drop time shift batchnum;
1
drop time shift batchnum;
2 Code Block
DATA Step
Explanation : This example illustrates dropping a range of variables ('grade1' to 'grade20') using range notation in the DROP statement. All variables within this range will be excluded from the output SAS data set.
Copied!
drop grade1-grade20;
1
drop grade1-grade20;
3 Code Block
DATA Step Data
Explanation : In this example, the variables 'purchase' and 'repair' are used for processing (calculating 'totcost'), but they are dropped from the output data set 'inventry'. The final data set 'inventry' will contain the variables 'unit', 'part', and 'totcost', but not 'purchase' or 'repair'. The 'infile file-specification' statement is a placeholder for the input file specification.
Copied!
data inventry;
drop purchase repair;
infile file-specification;
input unit part purchase repair;
totcost=sum(purchase,repair);
run;
1
DATA inventry;
2
drop purchase repair;
3
INFILE file-specification;
4
INPUT unit part purchase repair;
5
totcost=sum(purchase,repair);
6
RUN;
This material is provided "as is" by We Are Cas. There are no warranties, expressed or implied, as to merchantability or fitness for a particular purpose regarding the materials or code contained herein. We Are Cas is not responsible for errors in this material as it now exists or will exist, nor does We Are Cas provide technical support for it.
SAS and all other SAS Institute Inc. product or service names are registered trademarks or trademarks of SAS Institute Inc. in the USA and other countries. ® indicates USA registration. WeAreCAS is an independent community site and is not affiliated with SAS Institute Inc.
This site uses technical and analytical cookies to improve your experience.
Read more.