BookmarkSubscribeRSS Feed
🔒 This topic is solved and locked. Need further help from the community? Please sign in and ask a new question.
brophymj
Quartz | Level 8

I have a field Header1 ($20) of the form:

Header 1
485
1
AB27834
134
A/DD123
678423167
AB1266
12

and where the cell is a string where the characters are number I want to convert to the format;

0000000001 where Header1 is 1

0000000134 where Header1 is 134

and so on.

for the cells where the string contains a mix of letters and number I want to leave them as they are.

I tried using this code:

Header1new = put(input(header1,20.),z10.);

This converts the numbers the way I want but it produces loads of errors for the non-numbers. Is there code that allows for this i.e.

if the string header 1 contains at least one character then do leave as is.

Thanks

1 ACCEPTED SOLUTION

Accepted Solutions
ballardw
Super User

Almost there;

If anyalpha(Header1) = 0 then Header1new = put(input(header1,20.),z10.);

View solution in original post

2 REPLIES 2
ballardw
Super User

Almost there;

If anyalpha(Header1) = 0 then Header1new = put(input(header1,20.),z10.);

Tom
Super User Tom
Super User

You need to test if it is a number.  Also what about values that look like numbers such as:

1.5

12E5

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
  • 2 replies
  • 751 views
  • 0 likes
  • 3 in conversation