Help using Base SAS procedures

Format

Accepted Solution Solved
Reply
Super Contributor
Posts: 256
Accepted Solution

Format

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


Accepted Solutions
Solution
‎07-14-2015 10:17 AM
Super User
Posts: 10,466

Re: Format

Almost there;

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

View solution in original post


All Replies
Solution
‎07-14-2015 10:17 AM
Super User
Posts: 10,466

Re: Format

Almost there;

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

Super User
Super User
Posts: 6,497

Re: Format

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

1.5

12E5

☑ This topic is SOLVED.

Need further help from the community? Please ask a new question.

Discussion stats
  • 2 replies
  • 217 views
  • 0 likes
  • 3 in conversation