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

how to convert the Character decimal value to numeric decimal values?

 

1 ACCEPTED SOLUTION

Accepted Solutions
Reeza
Super User
You forgot the period after the format name, if you post the errors you get it's a lot more helpful and faster to debug.



68
69 data demo;
70 x="320.912";
71 Y=input(x, best32.);
72 run;

NOTE: The data set WORK.DEMO has 1 observations and 2 variables.
NOTE: DATA statement used (Total process time):
real time 0.00 seconds
user cpu time 0.01 seconds
system cpu time 0.00 seconds
memory 663.40k
OS Memory 23972.00k
Timestamp 11/25/2020 06:57:15 PM
Step Count 31 Switch Count 2
Page Faults 0
Page Reclaims 175
Page Swaps 0
Voluntary Context Switches 10
Involuntary Context Switches 0
Block Input Operations 0
Block Output Operations 272



Obs x Y
1 320.912 320.912

View solution in original post

6 REPLIES 6
Reeza
Super User
Depends, what does it look like?

NewVariable = input(characterVariable, Best32.);
SASuserlot
Barite | Level 11
Spoiler
 

x=320.912 ( character value)

Tried this code did not working

Y=input(x, best32);

Reeza
Super User
You forgot the period after the format name, if you post the errors you get it's a lot more helpful and faster to debug.



68
69 data demo;
70 x="320.912";
71 Y=input(x, best32.);
72 run;

NOTE: The data set WORK.DEMO has 1 observations and 2 variables.
NOTE: DATA statement used (Total process time):
real time 0.00 seconds
user cpu time 0.01 seconds
system cpu time 0.00 seconds
memory 663.40k
OS Memory 23972.00k
Timestamp 11/25/2020 06:57:15 PM
Step Count 31 Switch Count 2
Page Faults 0
Page Reclaims 175
Page Swaps 0
Voluntary Context Switches 10
Involuntary Context Switches 0
Block Input Operations 0
Block Output Operations 272



Obs x Y
1 320.912 320.912
juju_p
Obsidian | Level 7

Hello,

 

I have an issue with this!

 

I am trying to convert  text field (Type Text, informat $8.) into a decimal field so I use the format best32.

 

Here is my code:

DATA anc;
set lab_hem_s;
where LBTEST = 'Absolute neutrophil count (ANC)';
ANC = input (LBTEST, best32.);
/* informat ANC best.;*/
run;

 

The run generates error and I get missing values as shown below

 

NOTE: Invalid argument to function INPUT at line 362 column 11.
SUBJID=BLR-001-001 VISITT=Cycle 11 VISITD=11 LBTYPE=Haematology LBPRES=1 LBPREST=Yes LBREAS= DLBD=7 DLBM=9
DLBY=2020 LBTEST=Absolute neutrophil count (ANC) LBTESTND=. LBVAL=2.86 LBUNIT=10^9/L LBLLN=2.04 LBULN=5.8
LBRANGE=1 LBRANGET=Yes LBCS=. LBCST= LBCOM= HEMPART=Part 2 LBDAT=07SEP2020 ANC=. _ERROR_=1 _N_=19
NOTE: Invalid argument to function INPUT at line 362 column 11.
WARNING: Limit set by ERRORS= option reached. Further errors of this type will not be printed.
SUBJID=BLR-001-001 VISITT=End of treatment VISITD=20 LBTYPE=Haematology LBPRES=1 LBPREST=Yes LBREAS= DLBD=28
DLBM=9 DLBY=2020 LBTEST=Absolute neutrophil count (ANC) LBTESTND=. LBVAL=5.50 LBUNIT=10^9/L LBLLN=2.04
LBULN=5.8 LBRANGE=1 LBRANGET=Yes LBCS=. LBCST= LBCOM= HEMPART=Part 2 LBDAT=28SEP2020 ANC=. _ERROR_=1 _N_=20
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).
3061 at 362:11

 

Can someone help?

 

 

Reeza
Super User
According to the log, LBTEST=Absolute neutrophil count (ANC).

How do you convert that to a number?

Also, please post your question as new question in the future. Solved questions don't get much views, especially ones that are almost a year old.
juju_p
Obsidian | Level 7

Thanks a lot for your quick response! Indeed it was not the right variable to convert!

And I keep note to create a new post in the future 🙂

 

KRs

Justine

SAS Innovate 2025: Save the Date

 SAS Innovate 2025 is scheduled for May 6-9 in Orlando, FL. Sign up to be first to learn about the agenda and registration!

Save the date!

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.

SAS Training: Just a Click Away

 Ready to level-up your skills? Choose your own adventure.

Browse our catalog!

Discussion stats
  • 6 replies
  • 908 views
  • 2 likes
  • 3 in conversation