Hi All,
I have an input interval variable that has a range of negative and positive values. I want to transform the data so that all the negative values for this variable are changed to 0s. I connected my File Import node to the Rules Builder node and added the text below. Then I connected that to a Transform Variables node as I am changing some other variables, (not the ones I need to change the negative values to positives), then it is connected to a Data Partition Node and then a Stat Explore node. When I run everything and look at the results in the Stat Explore node I'm still seeing the negative values for the variables I need to change. Any idea what I'm doing wrong or how I can accomplish this? I appreciate all the help!
Rule in Rules Builder is...
EM_Outcome = "None";
IF Home_Team_Pitcher_s_FIP < 0.0 THEN DO;
EM_Outcome = "0";
END;
ELSE IF Visiting_Team_Pitcher_s_FIP < 0.0 THEN DO;
EM_Outcome = "0";
END;
If Em_outcome variable is numeric you cannot assign character values such as "None" or "0".
But if the Em_outcome variable is numeric, why wouldn't I be able to assign a numerical 0? Is there anyway that I can make the negative values 0 or no?
By assigning character values like "None" or "0", you implicitly define the variable as character if it does not yet exist. If the variable exists and is numeric, then the data step compiler will compile an automatic conversion which will fail for the value of "None" at runtime (see the log for NOTEs and ERRORs).
You are not changing existing variables, you create a new one which has the character value "0" when one of the incoming variables is negative.
To change an existing variable, do
home_team_pitcher_s_fip = max(home_team_pitcher_s_fip,0);
Hi All,
I have an input interval variable that has a range of negative and positive values. I want to transform the data so that all the negative values for this variable are changed to 0s. I connected my File Import node to the Rules Builder node and added the text below. Then I connected that to a Transform Variables node as I am changing some other variables, (not the ones I need to change the negative values to positives), then it is connected to a Data Partition Node and then a Stat Explore node. When I run everything and look at the results in the Stat Explore node I'm still seeing the negative values for the variables I need to change. Any idea what I'm doing wrong or how I can accomplish this? I appreciate all the help!
Rule in Rules Builder is...
EM_Outcome = "None";
IF Home_Team_Pitcher_s_FIP < 0.0 THEN DO;
EM_Outcome = "0";
END;
ELSE IF Visiting_Team_Pitcher_s_FIP < 0.0 THEN DO;
EM_Outcome = "0";
END;
SAS Innovate 2025 is scheduled for May 6-9 in Orlando, FL. Sign up to be first to learn about the agenda and registration!
SAS' Charu Shankar shares her PROC SQL expertise by showing you how to master the WHERE clause using real winter weather data.
Find more tutorials on the SAS Users YouTube channel.