Converting strings that are formatted as zoned decimals of varying length.

Reply
New Contributor
Posts: 2

Converting strings that are formatted as zoned decimals of varying length.

I am trying to convert a string to an integer, sometimes the string ends with {, }, or one of the other zoned decimal (overpunch) values.  The string is not always the same number of characters, sometimes the string has leading zeros and sometimes it does not.  Sometimes the string does not end with a zoned decimal (overpunch) value, and simple ends in a number.

Examples:

60F

000405484

66G

85463{

000{

000}

In this particular example the maximum length of the string is 9 characters, I have other columns that are more and others that are less.  For the 9 character maximum length column I tried using

INPUT(MyColumn,ZDV9.);

If the string was less than 9 characters I ended up with a NULL (.) value.

Can anyone help me with this problem?

Frequent Contributor
Posts: 85

Re: Converting strings that are formatted as zoned decimals of varying length.

INPUTN(MyColumn, CATS('ZDV' , LENGTH(MyColumn) , '.'))

I had a similar situation recently and this approach worked for me.

New Contributor
Posts: 2

Re: Converting strings that are formatted as zoned decimals of varying length.

That works for the signed decimal or overpunch rows, but it gives me a NULL for each row that isn't a signed decimal or an overpunch.  In my example 000405484 would be NULL if you ran it through INPUTN(MyColumn, CATS('ZDV' , LENGTH(MyColumn) , '.')).

Ask a Question
Discussion stats
  • 2 replies
  • 280 views
  • 0 likes
  • 2 in conversation