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

I have two numeric variables with 1 and 0 as data points.

data new;

set new1;

if a=1 and b=0 then out="bad" else bad="good";

run;

 

I am getting below error:

Note: Invalid Numeric data.

 

I cant change the dataset but how to change the code to handle this error

1 ACCEPTED SOLUTION

Accepted Solutions
Tom
Super User Tom
Super User

Paste the lines from the log for the data step and the notes/errors. Make sure to use the Insert Code button (looks like < / > ) to get a pop-up window to paste the lines so they are not re-flowed.

 

Your code at posted is missing a semi-colon.  It also looks strange as you are updating different variables in the THEN and ELSE clauses.  If the variable OUT is not already on the input dataset NEW1 then make sure to define it long enough to hold both values.  For example you could just add an extra space at the end of "bad " so that SAS sees you want room for 4 characters.

data new;
  set new1;
  if a=1 and b=0 then out="bad ";
  else out="good";
run;

View solution in original post

2 REPLIES 2
PaigeMiller
Diamond | Level 26

Show us the log, including the entire DATA step code and all NOTES, WARNINGS and ERRORs for this DATA step. Do not chop anything out of the log.

 

When providing the log, it is critical that you maintain the formatting of the log so we can see it exactly as SAS showed it to you, making it easier for us to use. To maintain the formatting of the log, click on the </> icon and paste the log as text into the window that appears. DO NOT SKIP THIS STEP.

--
Paige Miller
Tom
Super User Tom
Super User

Paste the lines from the log for the data step and the notes/errors. Make sure to use the Insert Code button (looks like < / > ) to get a pop-up window to paste the lines so they are not re-flowed.

 

Your code at posted is missing a semi-colon.  It also looks strange as you are updating different variables in the THEN and ELSE clauses.  If the variable OUT is not already on the input dataset NEW1 then make sure to define it long enough to hold both values.  For example you could just add an extra space at the end of "bad " so that SAS sees you want room for 4 characters.

data new;
  set new1;
  if a=1 and b=0 then out="bad ";
  else out="good";
run;

SAS Innovate 2025: Call for Content

Are you ready for the spotlight? We're accepting content ideas for SAS Innovate 2025 to be held May 6-9 in Orlando, FL. The call is open until September 25. Read more here about why you should contribute and what is in it for you!

Submit your idea!

Mastering the WHERE Clause in PROC SQL

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.

Discussion stats
  • 2 replies
  • 487 views
  • 0 likes
  • 3 in conversation