This week, we are discussing the CODE statement in some SAS® Enterprise Miner™ procedures.
Consider the following simple example that shows a modeling process from training to scoring.
The following flow diagram contains six nodes:
The data in the node named DMAGESCR have the same attributes as the German credit data, except that the latter contains the target good_bad. The scored data from the Save Data node contain all the attributes from DMAGESCR in addition to the predicted target, I_good_bad.
The score code that is exported from the Score Code Export node can be used to score other data sets.
As a SAS Enterprise Miner user, you can create a model and score a data set very quickly without using the GUI by using the CODE statement in SAS Enterprise Miner procedures.
The following SAS statements create the same HP Regression model as shown in Figure 1:
proc hplogistic data=sampsio.dmagecr ; class purpose / upcase ; model good_bad(order=internal descending ) = purpose age amount checking coapp depends duration employed existcr foreign history housing installp job marital other property resident savings telephon / link=LOGIT ; code file="score.sas" group=HPReg impute; run;
Here the SAS procedure HPLOGISTIC performs the model training and generates the score code. The score code file, "score.sas", is generated by the CODE statement and saved in the default location. You can also specify a path to store the file in a different location. After you have the score code, the scoring process is very simple. For example, the following statements apply the preceding score code to the scoring data sampsio.dmagescr:
data scoredata; set sampsio.dmagescr; %include "score.sas"; run;
The scored data set, scoredata, contains a new variable, I_good_bad, which is the prediction of the target good_bad in the original training data.
In this example, the CODE statement plays an important role and the file "score.sas" is the goal of the model training. The CODE statement is available in most of the frequently used SAS high-performance Enterprise Miner procedures. For example, you can find the CODE statement in HPSPLIT, HPLOGISTIC, HPREG, HPPRINCOMP, HPBIN, HPIMPUTE, HPCLUS, HPNEURAL, and HPSVM procedures.
For more information, please see the SAS Enterprise Miner website at http://www.sas.com/en_us/software/analytics/enterprise-miner.html or the SAS customer support website at http://support.sas.com/software/products/miner
Registration is open! SAS is returning to Vegas for an AI and analytics experience like no other! Whether you're an executive, manager, end user or SAS partner, SAS Innovate is designed for everyone on your team. Register for just $495 by 12/31/2023.
If you are interested in speaking, there is still time to submit a session idea. More details are posted on the website.
Data Literacy is for all, even absolute beginners. Jump on board with this free e-learning and boost your career prospects.