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.
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.
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.