DATA Step, Macro, Functions and more

Zoned Decimal informat

Reply
Contributor
Posts: 35

Zoned Decimal informat

[ Edited ]

Hello 

 

I have below data in a file and i want to read in a dataset 

 

this is how file looks 

 

 

00000000134623C

00000000153746E

00000000000085G

00000000017120E

 

Atually I am trying to read this file on SAS eg  tool.Actaully thiS program was running on mainframe and they were reading this like this  @1 mark S370FZD15.2 

 

I am trying to read it as  @1 mark 15.2 but it gives me error 

 

I want output to be 

13642.33

15374.65

8.57

1712.05

 

Thanks!!

Super User
Posts: 6,963

Re: Zoned Decimal informat

Using "base sas" as a subject line in the Base SAS Programming forum is, ahem, not very descriptive.

Therefore I changed your subject line.

When reading the documentation for the S370FZD informat, you'll notice a reference to the FZD informat, which does the same without converting from the mainframe's EBCDIC character set.

So do this:

data want;
input mark zd15.2;
cards;
00000000134623C
00000000153746E
00000000000085G
00000000017120E
;
run;
---------------------------------------------------------------------------------------------
Maxims of Maximally Efficient SAS Programmers
Contributor
Posts: 35

Re: Zoned Decimal informat

hello Kurt

sorry for putting wrong subject

Actually one of the values 00000000000529æ having this character æ is not coming correct .The output for this value comes as . But in mainframe it is coming as 52.90

How can I get that .Please guide

data want;
input mark zd15.2;
cards;
00000000134623C
00000000153746E
00000000000085G
00000000017120E
00000000000529æ
;
run;
Super User
Posts: 6,963

Re: Zoned Decimal informat

That looks like a problem when the file was copied from the mainframe. Be aware that mainframe codepages may have an influence here.

That's why I used to copy mainframe files in binary mode and use the s370 informats on UNIX.

 

Inspect the hex codes of the offending characters on the MF and after transfer on the new platform. Once you find a rule, read the data first as character, then translate the bad characters, and finallly use FZD. in an input statement.

Unless you can fix the transfer problem, of course.

---------------------------------------------------------------------------------------------
Maxims of Maximally Efficient SAS Programmers
Super User
Posts: 6,963

Re: Zoned Decimal informat

PS

 

"Workaround" code could look like this:

data want;
input markstr $15.;
markstr = translate(markstr,'F','e6'x);
mark = input(markstr,zd15.2);
cards;
00000000134623C
00000000153746E
00000000000085G
00000000017120E
00000000000529æ
;
run;
---------------------------------------------------------------------------------------------
Maxims of Maximally Efficient SAS Programmers
Ask a Question
Discussion stats
  • 4 replies
  • 61 views
  • 0 likes
  • 2 in conversation