BookmarkSubscribeRSS Feed
Patelbb
Fluorite | Level 6

Hi,

 

Can anyone please help me with my code. I'm not sure why the input function is not working and I've tried to play with it but nothing seems to fix it. Here is the log. I've shortened it bit since I was having posting this:

 

27  set dbsdtm.vs;
228  by usubjid;
229
230  length ftemp 8;
231  label ftemp = ?Temperature (F)?;
232
233  vsorresx = input(vsorres , best.);
234
235  if vsorresu = 'C' then ftemp = (vsorresx * 9 / 5) + 32;
236  if vsorresu = 'F' then ftemp = vsorresx;
237  else ftemp = .;
238
239  run;
NOTE: Invalid argument to function INPUT at line 233 column 12.
STUDYID=ABC-123 DOMAIN=VS USUBJID=1160-2508 VSSEQ=12 VSTESTCD=HNDDOM VSTEST=Hand Dominance VSORRES=RIGHT VSORRESU=
VSSTRESC=RIGHT VSSTRESN=. VSSTRESU=  VSSTAT=  VSREASND=  VSBLFL=Y VISITNUM=-1 VISIT=SCREENING EPOCH=SCREENING VSDTC=2013-01-25
VSTPT=  VSTPTNUM=. FIRST.USUBJID=0 LAST.USUBJID=0 ftemp=. vsorresx=. _ERROR_=1 _N_=12

NOTE: Mathematical operations could not be performed at the following places. The results of the operations have been set to
      missing values.
      Each place is given by: (Number of times) at (Line):(Column).
      77 at 233:12
NOTE: There were 3821 observations read from the data set DBSDTM.VS.
NOTE: The data set WORK.VITALS has 3821 observations and 21 variables.
NOTE: DATA statement used (Total process time):
      real time           0.09 seconds
      cpu time            0.09 seconds
 

Any help is appreciated! Thank you!

14 REPLIES 14
Tom
Super User Tom
Super User

As the log clearly shows you tried to convert 'RIGHT' to a number.

What number did you expect it to create?

 

PS There is not really any BEST informat. If you use that name it is just an alias for the normal numeric informat.  Plus the concept of a "best" informat doesn't even make any sense.

Reeza
Super User
Please use a descriptive subject line for your posts that better reflect your question. I've updated this question as an example.
PaigeMiller
Diamond | Level 26
NOTE: Invalid argument to function INPUT at line 233 column 12.
STUDYID=ABC-123 DOMAIN=VS USUBJID=1160-2508 VSSEQ=12 VSTESTCD=HNDDOM 
VSTEST=Hand Dominance VSORRES=RIGHT

Your input function has VSORRES as the first argument, and it is trying to convert something to best. format, which is a numeric format. The value of VSORRES is RIGHT, which can't be converted to a numeric format.

 

And @Tom  is correct, you can't use the best. informat there because there is no such informat.

--
Paige Miller
Patelbb
Fluorite | Level 6

So my input function isn't necessary then? If so, how do I go about fixing the code so that I don't get the note the character values have been converted to numeric?

PaigeMiller
Diamond | Level 26

@Patelbb wrote:

So my input function isn't necessary then? If so, how do I go about fixing the code so that I don't get the note the character values have been converted to numeric?


Well, at this time, none of us can answer this question. It's not a matter of fixing the code. It is a matter of you designing a meaningful process. You have to tell us what you want SAS to do when VSORRES has the value RIGHT.

--
Paige Miller
Patelbb
Fluorite | Level 6

 

So I want to create a working data set  that includes all the variables from the vital set dataset but also create a new variable (FTEMP) that will store only Fahrenheit temperature values (e.g. convert all Centigrade temperatures to Fahrenheit, copy the Fahrenheit temperatures, and remove all missing temperatures).  To do this, I know I have to look at the VSORRESU and VSORRES values. When I was looking at those variables I saw that they were character values and I needed to convert them into numeric so i could use them to convert the Celsius values to Farhenheit. 

PaigeMiller
Diamond | Level 26

@Patelbb wrote:

 

So I want to create a working data set  that includes all the variables from the vital set dataset but also create a new variable (FTEMP) that will store only Fahrenheit temperature values (e.g. convert all Centigrade temperatures to Fahrenheit, copy the Fahrenheit temperatures, and remove all missing temperatures).  To do this, I know I have to look at the VSORRESU and VSORRES values. When I was looking at those variables I saw that they were character values and I needed to convert them into numeric so i could use them to convert the Celsius values to Farhenheit. 


You have not addressed the issue, which I stated:

 

"You have to tell us what you want SAS to do when VSORRES has the value RIGHT."

 

Saying you want to convert RIGHT to numeric is a meaningless statement.

--
Paige Miller
Patelbb
Fluorite | Level 6

I'm sorry I don't understand what you mean...

PaigeMiller
Diamond | Level 26

You variable VSORRES has the value RIGHT, a character string. How do you convert it to numeric?

--
Paige Miller
Reeza
Super User

The log shows that this variable had the value of RIGHT (see the highlighted portion below).

 

NOTE: Invalid argument to function INPUT at line 233 column 12.
STUDYID=ABC-123 DOMAIN=VS USUBJID=1160-2508 VSSEQ=12 VSTESTCD=HNDDOM VSTEST=Hand Dominance VSORRES=RIGHT VSORRESU=
VSSTRESC=RIGHT VSSTRESN=. VSSTRESU=  VSSTAT=  VSREASND=  VSBLFL=Y VISITNUM=-1 VISIT=SCREENING EPOCH=SCREENING VSDTC=2013-01-25
VSTPT=  VSTPTNUM=. FIRST.USUBJID=0 LAST.USUBJID=0 ftemp=. vsorresx=. _ERROR_=1 _N_=12

 

Run a PROC FREQ on the variable you want to convert, VSORRES to see what types of values are in that column. 

If you have several variations you need to code for all of them to be handled. 

For example, you can use anydigit() to check for the presence of numbers. 

 

You can make your code execute conditionally:

 

if anydigit(vsorres) then measurement = input(vsorres, best12.);

or you can look at only temperature which is likely indicated in another variable. 

 

if otherVariable = 'Temperature' then temp = input(vsorres, 8.);
Patelbb
Fluorite | Level 6

Ok hold on I think I see where the confusion is. So VSORRES has several different values in and one of them is Temperature. There are other values such as blood pressure, height, hand domaniance, pulse and respiratory rate. So temperature is not the only value in this column. I just want to take only the temperature values from this column and convert those to farhenheit if they aren't already farhenheit. The VSORRES = RIGHT that you saw was in reference to the hand domaniance not temperature. So it looks like the input function didn't work on the hand domainance ones for some reason. But I also just checked my working dataset and the Celsius numbers have not converted to farhenheit.

Reeza
Super User

@Patelbb wrote:

So my input function isn't necessary then? If so, how do I go about fixing the code so that I don't get the note the character values have been converted to numeric?


Perhaps explain (comments in your code help this process) what you're trying to accomplish with that line of code? What did you think it did and what do you want to do with it?

 

 

 

 vsorresx = input(vsorres , best.);
Tom
Super User Tom
Super User

Are you sure you want to add a VARIABLE to this tall/skinny format?

Shouldn't you be adding an OBSERVATION instead?

 

But anyway the issue is you need to test whether the current observation has a temperature reading before trying to convert the temperature!

if vsorresu = 'C' then 
   ftemp = (input(vsorres,32.) * 9 / 5) + 32
;
else if vsorresu = 'F' then ftemp =  input(vsorres,32.);

 

Patelbb
Fluorite | Level 6

Ohh ok thank you so much!!!! This makes more sense now!!

hackathon24-white-horiz.png

The 2025 SAS Hackathon has begun!

It's finally time to hack! Remember to visit the SAS Hacker's Hub regularly for news and updates.

Latest Updates

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
  • 14 replies
  • 3269 views
  • 2 likes
  • 4 in conversation