DATA Step, Macro, Functions and more

input function

Reply
Contributor
Posts: 42

input function

Hi all,

 

I have an amount MT, which I extract from a file.

So at the beginning my amount is a char value

 

To transform it I use the following function:

input (MT, 20.2)

The problem is, it doesn't work efficiantely.

All of my amounts are actually numbers. In the file I will receive for exemple 186 instead of 186.00.

Nevertheless I don't want to treat them like number because they are amounts.

 

When I use the input function like this the results is the amount divided by 100. To come back to the previous example, in my output table I will have 1.86 instead of 186.00

 

How can I correct this?

 

Thanks

Super User
Posts: 7,762

Re: input function

Use the 20. informat. It will respect a dot in the input string, but not force the division by 10**2 as the 20.2 informat does.

---------------------------------------------------------------------------------------------
Maxims of Maximally Efficient SAS Programmers
Super User
Posts: 19,770

Re: input function

Use a BEST format instead of 20.2.

When you use 20.2 it always expects 2 decimal places, BEST will look at what it is. You can format it after to look like whatever you want.

 

new_MT = input (MT, best32.);
format new_MT 20.2;
Ask a Question
Discussion stats
  • 2 replies
  • 142 views
  • 0 likes
  • 3 in conversation