BookmarkSubscribeRSS Feed

Tip: The CODE Statement in SAS® Enterprise Miner™ Procedures

Started ‎07-30-2014 by
Modified ‎01-06-2016 by
Views 2,371
 

 

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:

 

  • an Input Data Source node that uses the German credit data (sampsio.dmagecr) as the training data  
  • an HP Regression node that uses the SAS high-performance regression model  
  • a Score node to generate SAS score code for the model  
  • a Score Code Export node to export the generated SAS score code  
  • an Input Data Source node that uses the German credit data (sampsio.dmagescr) as the score data  
  • a Save Data node to save the training and scoring results
hplogistic.jpg 
Figure 1

 

 

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

Version history
Last update:
‎01-06-2016 01:40 PM
Updated by:

sas-innovate-2024.png

Don't miss out on SAS Innovate - Register now for the FREE Livestream!

Can't make it to Vegas? No problem! Watch our general sessions LIVE or on-demand starting April 17th. Hear from SAS execs, best-selling author Adam Grant, Hot Ones host Sean Evans, top tech journalist Kara Swisher, AI expert Cassie Kozyrkov, and the mind-blowing dance crew iLuminate! Plus, get access to over 20 breakout sessions.

 

Register now!

Free course: Data Literacy Essentials

Data Literacy is for all, even absolute beginners. Jump on board with this free e-learning  and boost your career prospects.

Get Started

Article Tags