I have the following number in character format. How Can I change that into the numeric form, including spaces? Is that possible?
'012932 01 001'
In SAS numeric values can only contain digits 0-9, decimals and E for scientific notation. But you can create a custom format to display the value in the pattern you want, but you must convert the original character to a number. See steps below:
Sorry for the confusion. I mean to say the format of the number like how @JOL and @ballardw explained in the solution.
Thank you for asking more questions so that I learn to be precise.
In SAS numeric values can only contain digits 0-9, decimals and E for scientific notation. But you can create a custom format to display the value in the pattern you want, but you must convert the original character to a number. See steps below:
@SASuserlot wrote:
I have the following number in character format. How Can I change that into the numeric form, including spaces? Is that possible?
'012932 01 001'
And what number would that be?
Looks like THREE numbers to me. Or really TWO different numbers. 1 is written two different ways because of different number of leading zeros. A the first number (12,932) is also written with a leading zero.
@SASuserlot wrote:
I have the following number in character format. How Can I change that into the numeric form, including spaces? Is that possible?
'012932 01 001'
And just what numeric value would that have? Since spaces are not normally part of a number we need to know exactly what numeric value you expect that to have.
What calculations are you going to sue with this numeric value? If the answer is "none" then don't bother, you are just adding complexity.
You can create a custom format to display numeric values in that format but without details it may be insufficient. Example:
proc format; picture sss low-high ='00000 00 009' ; run; data _null_; input x; put x= sss. ; datalines; 1 12 123 1234 12345 123456 1234567 12345678 123456789 1234567890 ;
OR
proc format; picture sss low-high ='99999 99 999' ; run; data _null_; input x; put x= sss. ; datalines; 1 12 123 1234 12345 123456 1234567 12345678 123456789 1234567890 ;
The log shows some formatted values but would likely need some details as to actual appearance
Are you ready for the spotlight? We're accepting content ideas for SAS Innovate 2025 to be held May 6-9 in Orlando, FL. The call is open until September 16. Read more here about why you should contribute and what is in it for you!
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.
Select SAS Training centers are offering in-person courses. View upcoming courses for: