I have imported a series of account numbers (not the real ones showing below) but imported as text. I have some account numbers that have a leading 0 and some account numbers are different lengths .. Below are some examples. I need to keep this account number field as numeric with the leading 0 where it should be and with the different length as required.
Example
Acct_no
12345678
01234567
123456
0123456789
So they currently import as text, but I want them to be the way they are, however converted as numeric.
Thanks
Impossilbe numeric, decimal numeric does not exist. See also: https://communities.sas.com/message/228508#228508. It is the digital age.
You didn't post what output you want yet .
The output looking as is, but in numeric.
Acct_no
12345678
01234567
123456
0123456789
You seem confused on the concept of numbers versus character strings. If you store your account ids as numbers then there is no way to distinguish between the values 123 and 0000123 since when you convert those character strings into numbers they are both one hundred and twenty three.
You can attach formats to numbers to have them displayed in different ways. So you could store 123 as a number and attached the Z7. format to it. Then when it is printed in a a report it will look like 0000123. But the format is attached to the variable and not to just a particular value. SAS stores data in data sets and not in a cells like a spreadsheets. So you cannot use a different format on different observations of the data.
So you have two choices.
1) Store your account id as a character string. This is the most logical as it is NOT a number (even if people do call them account "numbers") but an identifier. You will not be taking the mean or square root of your account ids.
2) Add another variable. So if you wanted to treat 123 and 0000123 as different in some way you need another variable to distinguish them. It could be the number of digits. (123,3) vs (123,7) It could be an actual format (123,'Z3.') vs (123,'Z7.).
I think I get it.. thanks
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 25. Read more here about why you should contribute and what is in it for you!
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.