BookmarkSubscribeRSS Feed
fabdu92
Obsidian | Level 7

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

2 REPLIES 2
Reeza
Super User

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;

sas-innovate-2024.png

Don't miss out on SAS Innovate - Register now for the FREE Livestream!

Can't make it to Vegas? No problem! Watch our general sessions LIVE or on-demand starting April 17th. Hear from SAS execs, best-selling author Adam Grant, Hot Ones host Sean Evans, top tech journalist Kara Swisher, AI expert Cassie Kozyrkov, and the mind-blowing dance crew iLuminate! Plus, get access to over 20 breakout sessions.

 

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
  • 2 replies
  • 670 views
  • 0 likes
  • 3 in conversation