If you have a comma in a text field using the comma8. input statement works; the best will not format it correctly and continue with the same problem.
@SuperSas1 wrote:
If you have a comma in a text field using the comma8. input statement works; the best will not format it correctly and continue with the same problem.
Not sure why you are responding to an ancient thread....
The INPUT() function does not mind if the width used on the informat is larger than the length of the string being read, so in general you should just use the maximum width that the informat supports. For COMMA that is 32.
number = input(string,comma32.);
Also notice that do not want to include a decimal width on an informat except for the rare occasion when you know the strings being read were created explicitly without the decimal point and want SAS to divide by that power of 10 to insert one. This is normally not done for strings that include commas.
Note also the BEST is the name of a FORMAT. Its name comes from its attempt to find the "best" way to display a number in a limited number of characters. There is no corresponding concept of the "best" way to store a string as a number. Numbers in SAS can only be stored one way, as 64 bit binary floating point values. If you use BEST as an informat then SAS just assumes you meant to use the normal numeric informat, which does not work with strings that contain commas.
Registration is now open for SAS Innovate 2025 , our biggest and most exciting global event of the year! Join us in Orlando, FL, May 6-9.
Sign up by Dec. 31 to get the 2024 rate of just $495.
Register now!
Learn the difference between classical and Bayesian statistical approaches and see a few PROC examples to perform Bayesian analysis in this video.
Find more tutorials on the SAS Users YouTube channel.
Ready to level-up your skills? Choose your own adventure.