DATA Step, Macro, Functions and more

Packed decimal question

Accepted Solution Solved
Reply
Frequent Contributor
Posts: 124
Accepted Solution

Packed decimal question

Greetings all.  I'm attempting to read data from a tape on a zOS mainframe.  I think what we refer to as "tape" may actually be a disk, but that is another matter.  My question is this:  I have a document showing the file layout, and there are scads of packed decimal fields with a '+' and some number after the PD format, and both are wrapped in parenthesis.  For example, if I have "@2156 (TOT1 - TOT24) (PD5.0 +242)", what does the "+242" mean.  I know there are 24 fields here, but there is also "@2161 (NextField1-NextField24) ($ 18. +229)"  I cannot fathom how, even using packed decimal, there could be 24 fields in the space between 2156 and 2161.  Any insight would be greatly appreciated.  Thank you.

Greg


Accepted Solutions
Solution
‎02-21-2013 10:37 AM
Super User
Posts: 5,500

Re: Packed decimal question

Greg,

As you have seen with the NextField variables, the questions here revolve around the INPUT statement.  The fact that some fields are packed decimal is a separate issue, and doesn't really impact the answer.

The form of INPUT you are looking at:

@2156 (TOT1 - TOT24) (PD5.0 +242)

This means that the same instructions (PD5.0 +242) should be applied when reading every variable in the list (TOT1 - TOT24).  So SAS begins by reading TOT1.  Start at column 2156 of the incoming data line, read 5 characters (PD5.0), which positions the software at column 2161.  Then move 242 spaces to the right, positioning the software at column 2403.  Then apply the same instructions to read TOT2.  Read the 5 characters starting at column 2403, and positioning the software at column 2408.  Then move 242 spaces to the right, positioning at column 2650.  Then read TOT3, etc.

Hope I've done the math right here.  Either way, the idea is that the same instructions should apply when reading every variable in the list.

Good luck.

View solution in original post


All Replies
Solution
‎02-21-2013 10:37 AM
Super User
Posts: 5,500

Re: Packed decimal question

Greg,

As you have seen with the NextField variables, the questions here revolve around the INPUT statement.  The fact that some fields are packed decimal is a separate issue, and doesn't really impact the answer.

The form of INPUT you are looking at:

@2156 (TOT1 - TOT24) (PD5.0 +242)

This means that the same instructions (PD5.0 +242) should be applied when reading every variable in the list (TOT1 - TOT24).  So SAS begins by reading TOT1.  Start at column 2156 of the incoming data line, read 5 characters (PD5.0), which positions the software at column 2161.  Then move 242 spaces to the right, positioning the software at column 2403.  Then apply the same instructions to read TOT2.  Read the 5 characters starting at column 2403, and positioning the software at column 2408.  Then move 242 spaces to the right, positioning at column 2650.  Then read TOT3, etc.

Hope I've done the math right here.  Either way, the idea is that the same instructions should apply when reading every variable in the list.

Good luck.

Trusted Advisor
Posts: 2,115

Re: Packed decimal question

Checkout the documentation for the SAS INFORMAT controls

SAS(R) 9.2 Language Reference: Dictionary, Fourth Edition

@2156 (TOT1 - TOT24) (PD5.0 +242)

means to pick up tot1 starting at column 2156 and tot2 starting at column 2156+242, etc.  It is not PD specific.

Doc Muhlbaier

Duke

Frequent Contributor
Posts: 124

Re: Packed decimal question

Thank you both so much for the help, I was struggling to understand what was going on.

Greg

🔒 This topic is solved and locked.

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

Discussion stats
  • 3 replies
  • 232 views
  • 3 likes
  • 3 in conversation