Usage Note 24470: How do I use the SAS Code node in the SAS® Enterprise Miner™ 5.x series to perform my own data manipulations?
You can create a SAS data set from within the SAS Code node by naming the data set in the DATA step that creates it. For example, if you are using a DATA step to create a data set, then name the data set in the DATA statement as you would in regular SAS programming:
DATA SASUSER.NEW_OUTPUT;
SET SASHELP.CLASS;
IF AGE < 13 then AGEGROUP=1;
ELSE IF AGE >= 13 AND AGE < 16 THEN AGEGROUP=2;
ELSE IF AGE >= 16 THEN AGEGROUP=3;
RUN;
The data set SASUSER.NEW_OUTPUT is created by the SAS Code node. Be aware that each node runs with its own WORK library on the SAS Workspace Server. A WORK data set that you create in a SAS Code node is not available to a successor node. This behavior is distinctly different from the SAS Enterprise Miner 4.x series.
If you want the generated data set to be "in line" with the diagram flow, to accept a data set from the predecessor node, and to forward the data set to the successor node, then you should name the data sets in the DATA and SET statements using macro variables. This ensures the data is read and written with names that SAS Enterprise Miner maintains.
Select the SAS Code node in your diagram. Select the ellipses (...) to the right of SAS Code under the Training property. The Macro Variables tab in the SAS Code node window displays the currently defined macro variables. Identify the macro name that references the data that you want to read. For example, if you want to modify your training data within the SAS Code node, scroll through the macro variables that are listed in the Imports section. The macro variable that defines the data from the predecessor node is EM_IMPORT_DATA. Do the same for the data set that you want to create by identifying the appropriate macro variable name under the Exports listing.
When you know the macro variables to use, you can write your code within the SAS Code tab of the SAS Code node window. Your code might look something like this:
DATA &EM_EXPORT_TRAIN;
SET &EM_IMPORT_DATA;
IF AGE < 13 then AGEGROUP=1;
ELSE IF AGE >= 13 AND AGE < 16 THEN AGEGROUP=2;
ELSE IF AGE >= 16 THEN AGEGROUP=3;
RUN;
Operating System and Release Information
| SAS System | SAS Enterprise Miner | All | n/a | |
*
For software releases that are not yet generally available, the Fixed
Release is the software release in which the problem is planned to be
fixed.
| Type: | Usage Note |
| Priority: | low |
| Topic: | Analytics ==> Power and Sample Size Analytics ==> Data Mining
|
| Date Modified: | 2009-01-12 09:28:40 |
| Date Created: | 2005-12-23 16:47:19 |