Published on :
Variable Control CREATION_INTERNE

Sans titre

This code is also available in: Deutsch Español Français
Awaiting validation
If the option is associated with an input data set, the variables are not available for processing. If the DROP= data set option is associated with an output data set, SAS© does not write the variables to the output data set, but they are available for processing. The documentation also compares the DROP= option to the DROP statement, noting that DROP= can apply to both input and output data sets in DATA steps, while the DROP statement applies only to output data sets. Furthermore, in PROC steps, only the DROP= option can be used.
Data Analysis

Type : CREATION_INTERNE


Examples use generated data (datalines) or SASHELP.

1 Code Block
DATA STEP Data
Explanation :
In this example, the SALARY and GENDER variables are not included in the processing of the PAYROLL data set and are not written to the output data sets PLAN1 or PLAN2. The DATA statement cannot reference SALARY or GENDER in its logic because the DROP= option prevents them from being read by the SET statement.
Copied!
1LIBNAME mylib 'home/userid/mydata';
2 
3DATA _null_;
4 INPUT id name $ salary gender $ hired date9.;
5 DATALINES;
61 John 50000 M 01JAN1997
72 Jane 60000 F 01JAN1999
83 Mike 45000 M 01FEB1998
94 Emily 70000 F 01MAR2000
10;
11RUN;
12 
13DATA payroll;
14 SET _null_;
15RUN;
16 
17DATA plan1 plan2;
18 SET payroll(drop=salary gender);
19 IF hired<'01jan98'd THEN OUTPUT plan1;
20 ELSE OUTPUT plan2;
21RUN;
2 Code Block
DATA STEP Data
Explanation :
In this example, SALARY and GENDER are available for processing in the DATA step but are not written to the PLAN2 data set. However, they are written to the PLAN1 data set. This demonstrates how the DROP= option can be used specifically for an output data set, allowing variables to be processed internally while controlling their inclusion in the final data sets.
Copied!
1LIBNAME mylib 'home/userid/mydata';
2 
3DATA _null_;
4 INPUT id name $ salary gender $ hired date9.;
5 DATALINES;
61 John 50000 M 01JAN1997
72 Jane 60000 F 01JAN1999
83 Mike 45000 M 01FEB1998
94 Emily 70000 F 01MAR2000
10;
11RUN;
12 
13DATA payroll;
14 SET _null_;
15RUN;
16 
17DATA plan1 plan2(drop=salary gender);
18 SET payroll;
19 IF hired<'01jan98'd THEN OUTPUT plan1;
20 ELSE OUTPUT plan2;
21RUN;
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.