BookmarkSubscribeRSS Feed
Malathi13
Obsidian | Level 7

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

11 REPLIES 11
HB
Barite | Level 11 HB
Barite | Level 11

I would guess looking at the data in line 353 of test would be a place to start.

 

Malathi13
Obsidian | Level 7

Thank you, I got the answer!!. One of the observation was numeric in that Variable, I deleted that and I got the answer.

Tom
Super User Tom
Super User

@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.

 

Malathi13
Obsidian | Level 7

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

art297
Opal | Level 21

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

 

Malathi13
Obsidian | Level 7
I made error in typing but the code I have is correct. Sorry for spelling mistakes. It’s disposition and in my actual code I have single quotes. I did see that I mixed the codes here while writing. It’s ‘Treated’ not ‘Treated”. Good catch.
Shmuel
Garnet | Level 18

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.

       

 

 

art297
Opal | Level 21

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

 

ballardw
Super User

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
Barite | Level 11 HB
Barite | Level 11
@ballardw That is both new to me and very slick.
ballardw
Super User

@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.

sas-innovate-2024.png

Join us for SAS Innovate April 16-19 at the Aria in Las Vegas. Bring the team and save big with our group pricing for a limited time only.

Pre-conference courses and tutorials are filling up fast and are always a sellout. Register today to reserve your seat.

 

Register now!

How to Concatenate Values

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.

Click image to register for webinarClick image to register for webinar

Classroom Training Available!

Select SAS Training centers are offering in-person courses. View upcoming courses for:

View all other training opportunities.

Discussion stats
  • 11 replies
  • 6273 views
  • 3 likes
  • 6 in conversation