BookmarkSubscribeRSS Feed
🔒 This topic is solved and locked. Need further help from the community? Please sign in and ask a new question.
SwapnaKumari
Fluorite | Level 6

Hi All,

 

Trying to write Proc DS2 code for SAS ESP model, below is the code exported from EMiner:-

 

length _WARN_ $4;

label _WARN_ = 'Warnings' ;

 

length I_Failure $ 12;

label I_Failure = 'Into: Failure' ;

*** Target Values;

array REG2DRF [2] $12 _temporary_ ('1' '0' );

label U_Failure = 'Unnormalized Into: Failure' ;

format U_Failure BEST12.;

*** Unnormalized target values;

ARRAY REG2DRU[2] _TEMPORARY_ (1 0);

 

drop _DM_BAD;

_DM_BAD=0;

 

*** Check Coolant_Level for missing values ;

if missing( Coolant_Level ) then do;

substr(_warn_,1,1) = 'M';

_DM_BAD = 1;

end;

 

*** Check Noise for missing values ;

if missing( Noise ) then do;

substr(_warn_,1,1) = 'M';

_DM_BAD = 1;

end;

 

*** Check Oil_Temparature for missing values ;

if missing( Oil_Temparature ) then do;

substr(_warn_,1,1) = 'M';

_DM_BAD = 1;

end;

 

*** Check Speed for missing values ;

if missing( Speed ) then do;

substr(_warn_,1,1) = 'M';

_DM_BAD = 1;

end;

*** If missing inputs, use averages;

if _DM_BAD > 0 then do;

_P0 = 0.2055244985;

_P1 = 0.7944755015;

goto REG2DR1;

end;

 

*** Compute Linear Predictor;

drop _TEMP;

drop _LP0;

_LP0 = 0;

 

*** Effect: Coolant_Level ;

_TEMP = Coolant_Level ;

_LP0 = _LP0 + ( 0.03716283327255 * _TEMP);

 

*** Effect: Noise ;

_TEMP = Noise ;

_LP0 = _LP0 + ( 1.90253038267245 * _TEMP);

 

*** Effect: Oil_Temparature ;

_TEMP = Oil_Temparature ;

_LP0 = _LP0 + ( 0.05477217759604 * _TEMP);

 

*** Effect: Speed ;

_TEMP = Speed ;

_LP0 = _LP0 + ( 0.00222458951872 * _TEMP);

 

*** Naive Posterior Probabilities;

drop _MAXP _IY _P0 _P1;

_TEMP = -180.133287153081 + _LP0;

if (_TEMP < 0) then do;

_TEMP = exp(_TEMP);

_P0 = _TEMP / (1 + _TEMP);

end;

else _P0 = 1 / (1 + exp(-_TEMP));

_P1 = 1.0 - _P0;

 

REG2DR1:

 

 

*** Posterior Probabilities and Predicted Level;

label P_Failure1 = 'Predicted: Failure=1' ;

label P_Failure0 = 'Predicted: Failure=0' ;

P_Failure1 = _P0;

_MAXP = _P0;

_IY = 1;

P_Failure0 = _P1;

if (_P1 > _MAXP + 1E-8) then do;

_MAXP = _P1;

_IY = 2;

end;

I_Failure = REG2DRF[_IY];

U_Failure = REG2DRU[_IY];

 

*************************************;

***** end scoring code for regression;

*************************************;

*------------------------------------------------------------*;

* TOOL: Score Node;

* TYPE: ASSESS;

* NODE: Score2;

*------------------------------------------------------------*;

*------------------------------------------------------------*;

* Score2: Creating Fixed Names;

*------------------------------------------------------------*;

LABEL EM_EVENTPROBABILITY = 'Probability for level 1 of Failure';

EM_EVENTPROBABILITY = P_Failure1;

LABEL EM_PROBABILITY = 'Probability of Classification';

EM_PROBABILITY =

max(

P_Failure1

,

P_Failure0

);

LENGTH EM_CLASSIFICATION $%dmnorlen;

LABEL EM_CLASSIFICATION = "Prediction for Failure";

EM_CLASSIFICATION = I_Failure;

 

I am able to convert most of the part except the array, can anyone please help me to convert this code in proc DS2 for use in SAS Event stream processing.

 

Thanks in advance.

 

Regards,

Swapna

1 ACCEPTED SOLUTION

Accepted Solutions
Reeza
Super User

The array only has 2 values so replace the logic in the IF THEN with a longer IF THEN type structure to get the values. 

 

 

View solution in original post

3 REPLIES 3
Reeza
Super User

The array only has 2 values so replace the logic in the IF THEN with a longer IF THEN type structure to get the values. 

 

 

SwapnaKumari
Fluorite | Level 6

Thank you Reeza for the help... 🙂

 

Regards,

Swapna

Ram12a
Calcite | Level 5

SAS Event stream processing: 

 

Any suggestion to try SAS Event stream processing in python to cross validate.

 

Thanks

Whether you're already using SAS Event Stream Processing or thinking about it, this is where you can connect with your peers, ask questions and find resources.

 

Multiple Linear Regression in SAS

Learn how to run multiple linear regression models with and without interactions, presented by SAS user Alex Chaplin.

Find more tutorials on the SAS Users YouTube channel.

Discussion stats
  • 3 replies
  • 1838 views
  • 0 likes
  • 3 in conversation