BookmarkSubscribeRSS Feed
Rum
Calcite | Level 5 Rum
Calcite | Level 5
Hi anyone,

I'm working on data extraction part in mainframe using sas scripts.one of my column have datatype as S9(10) comp-3 to read this I used PD6 and Z10. But, it produced zeros for me.. pls anyone suggest me best idea how to read this
6 REPLIES 6
ballardw
Super User

What does your log show for this step? Best is to copy the text from the log with any notes, warning or error messages and then on the forum open a text box using the </> icon above the message window and paste all the text. The text box helps maintain formatting of any diagnostic messages that SAS provides.

Rum
Calcite | Level 5 Rum
Calcite | Level 5
There is no error message in log ..after converting source file to dat using sas Im getting zeros on this column..
Tom
Super User Tom
Super User

@Rum wrote:
There is no error message in log ..after converting source file to dat using sas Im getting zeros on this column..

Show the code. Show the data.

 

If you are reading in the value from some file then try reading the set of bytes using $CHAR informat and then print them using $HEX to see what values you actually have in the file.

 

Then try convert those values into what you want.  Read the documentation on the PD informat.

Notice the warning message:

 

Note: Different operating environments store packed decimal values in different ways. However, PDw.d reads packed decimal values with consistent results if the values are created in the same type of operating environment that you use to run SAS.

 

If the text file was made on an IBM mainframe and you are reading it on some other platform then you might need to use the S370FPD informat instead.

Rum
Calcite | Level 5 Rum
Calcite | Level 5
i specified this as in input as @1 rec_id PD6 and at output as Z10. Both source and dat file conversion doing on mainframe not out of it that
Tom
Super User Tom
Super User

@Rum wrote:
i specified this as in input as @1 rec_id PD6 and at output as Z10. Both source and dat file conversion doing on mainframe not out of it that

So you seem to be saying you have program something like this:

data want;
  infile myfile ;
  input @1 rec_id pd6.;
  format rec_id Z10.;
run;

So take a look at what is actually in the 6 bytes at the start of the record.  You could use the LIST statement to have SAS dump the data to the log.  You could read the value into a character string and print it with the $HEX format to see what it has.  So perhaps something like this:

data want;
  infile myfile ;
  input @1 rec_id_hex $char6. @1 rec_id pd6.;
  format rec_id Z10. rec_id_hex $hex.;
run;

Once you have some of the example values share them with us and we can help you check if they really are in PD format or not.

 

For example here is little program you try running to see what PD values should look like:

data test;
  do integer=1 to 4000 by 500;
    pd = put(integer,pd6.);
    s370fpd = put(integer,s370fpd6.);
    output;
  end;
  format pd s370fpd $hex.;
run;

Results when run on Windows.

Obs    integer         pd           s370fpd

 1          1     000000000001    00000000001C
 2        501     000000000501    00000000501C
 3       1001     000000001001    00000001001C
 4       1501     000000001501    00000001501C
 5       2001     000000002001    00000002001C
 6       2501     000000002501    00000002501C
 7       3001     000000003001    00000003001C
 8       3501     000000003501    00000003501C

 Notice how the S370FPD format has that hex digit C in the last nibble of the last byte while the PD format on Windows does not.

SAS Innovate 2025: Call for Content

Are you ready for the spotlight? We're accepting content ideas for SAS Innovate 2025 to be held May 6-9 in Orlando, FL. The call is open until September 25. Read more here about why you should contribute and what is in it for you!

Submit your idea!

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