BookmarkSubscribeRSS Feed
Rohit12
Obsidian | Level 7

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!!

4 REPLIES 4
Kurt_Bremser
Super User

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;
Rohit12
Obsidian | Level 7
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;
Kurt_Bremser
Super User

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.

Kurt_Bremser
Super User

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;

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!

How to Concatenate Values

Learn how use the CAT functions in SAS to join values from multiple variables into a single value.

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