Hi,
I'm getting a
NOTE: Invalid numeric data, Disposition='TREATED TRANSPORTED', at line
353 column 8.
I have the following code:
data new;
set test;
if Disposition= 'Canceled, No Patient Contact' then Disposition= 'Canceled';
if Disposition= 'Unresponsive– Pronounced' or Disposition eq 'dead' then Disposition='Dead';
if Disposition= 'Treated Transported' or Disposition= 'Treated and transported' then Disposition='TREATED TRANSPORTED';
if Disposition= 'Treated and Released (per protocol)' then Disposition='Treated and Released';
run;
NOTE: Invalid numeric data, Disposition='TREATED TRANSPORTED' , at line
353 column 8.
I looked at other previous responses to Invalid numeric data errors, but I didn't get the answer for this. I tried all the suggestions but they didn't work for my code.
Can anybody help me with this.
Thank you
M
I would guess looking at the data in line 353 of test would be a place to start.
Thank you, I got the answer!!. One of the observation was numeric in that Variable, I deleted that and I got the answer.
@Malathi13 wrote:
Thank you, I got the answer!!. One of the observation was numeric in that Variable, I deleted that and I got the answer.
Glad you fixed your problem, but that statement makes no sense. A variable has the same type for every observation in a dataset. SAS datasets are not spreadsheets. And even if your error was caused by code that was attempting to convert a character variable into a number such as :
disposition = disposition + 1;
then ithe one observation that held a string that looked like a number that would be the one that did NOT generate an error or warning.
Hi All,
Thank you for your suggestions.
Tom,
to give you an expiation of my data, variable disposition is character but one of the observation in that variable as 1.
E.x. Dispostion
Treated
Treated and Transported
Dead
1
Transferred
Pronounced Dead
that's what I have in the dataset for Variable Disposition. When I used if-then to delete, I used
if disposition='Treated" then disposition='Treated and Transported';
if deposition=1 then delete;
if disposition='Pronounced Dead' then disposition='Dead';
that's when I was getting that NOTE: Invalid numeric error. I fixed it by adding quotations to 1 (see below) and my error got fixed.
if disposition='1' then delete;
Thank you
M
Now the error you received makes perfect sense and, yes, putting quotes around the 1 will resolve that particular error.
However, you code has other mistakes. e.g.:
if disposition='Treated" then disposition='Treated and Transported';
You can't mix single and double quotes. It would have to be either 'Treated' or "Treated"
if deposition=1 then delete;
Are you trying to evaluate desposition or disposition?
Art, CEO, AnalystFinder.com
I guess DISPOSITION is defined as numeric in your input with a format displaying text.
1) Run proc contents for your input dataset. Is this field realy defined as numeric ? and what format is attached to it ?
proc contents data=test; run;
2) Assuming there is a format then run:
proc format lib=<format catalog library> list;
select <format name>;
run;
then replace your code to check for the numeric code and assign numeric code - instead dealing with textual value.
3) Alternatively you can use PUT/INPUT functions with the format/informat to create a new char type variable.
I would run proc contents on the dataset. Sounds like disposition is actually a numeric field and what you really want to do is change the format that is being applied to it.
Art, CEO, AnalystFinder.com
Try copy and pasting the entire code and messages from the log for that data step into a code box opened with the forum {I} menu icon.
We cant tell which line or column of our code (though I can guess I hate doing that).
If you do this sort of thing frequently then you might want to learn the select statement
select (Disposition); When ('Canceled, No Patient Contact') Disposition= 'Canceled'; When ('Unresponsive– Pronounced', 'dead') Disposition='Dead'; When ('Treated Transported' ,'Treated and transported') Disposition='TREATED TRANSPORTED'; When ('Treated and Released (per protocol)' Disposition='Treated and Released'; otherwise; /* do nothing*/ end;
@HB wrote:
@ballardw That is both new to me and very slick.
@HB Select is very good way to deal with things that many folks do multiple if/then/else. Note that the When result can also be a DO/End block of code.
The main obstacle is dealing with ranges of numeric as order can become very important such as with:
grade = select when (score >= 90) 'A' when (score >= 80) 'B' when (score >= 70) 'C' when (score >= 60) 'D' when (score >= 0 ) 'F' end;
Note that changing the order of the whens above could result in a significantly different grade.
Which points a modification of my earlier post which is left to the interested reader.
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!
Learn how use the CAT functions in SAS to join values from multiple variables into a single value.
Find more tutorials on the SAS Users YouTube channel.