BookmarkSubscribeRSS Feed
podarum
Quartz | Level 8

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

5 REPLIES 5
jakarman
Barite | Level 11

Impossilbe numeric, decimal numeric does not exist.  See also:  https://communities.sas.com/message/228508#228508. It is the digital age.  

---->-- ja karman --<-----
Ksharp
Super User

You didn't post what output you want yet .

podarum
Quartz | Level 8

The output looking as is, but in numeric.

Acct_no

12345678

01234567

123456

0123456789

Tom
Super User Tom
Super User

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

podarum
Quartz | Level 8

I think I get it.. thanks

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!

What is Bayesian Analysis?

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.

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
  • 5 replies
  • 1117 views
  • 0 likes
  • 4 in conversation