SAS TO COBOL 转换变量声明 [英] SAS TO COBOL conversion variable declaration

查看:35
本文介绍了SAS TO COBOL 转换变量声明的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

朋友,

我正在做 SAS 到 COBOL 的转换.我坚持下面的声明和转换.所以我在 COBOL 运行中得到了 SOC7.请提供一些解决方案.

I am doing SAS to COBOL conversion.I am stuck with below declaration and conversion.So I am getting SOC7 in COBOL run.Please provide some solution.

                     IP in SAS - PD3.5
                      OP in SAS - z6.5

我的 COBOL 声明如下.IP s9.9(5);OP .9(5);

My COBOL declaration below. IP s9.9(5); OP .9(5);

请提出一些解决方案..

Please suggest some solution..

非常感谢!!

推荐答案

压缩十进制每半字节存储一位,即每字节两位,最后一个半字节存储符号.符号半字节 C、A、F 和 E 被视为正数;符号半字节 B 和 D 被视为负数.符号半字节C和D被称为优选符号".F 的符号半字节被认为是无符号的".这意味着它既不是正数也不是负数,但从实用角度来说,您可以将其视为算术目的的正数.+123 以两个字节存储为 x'123C',-456 存储为 x'456D'.

Packed Decimal is stored one digit per nibble, which is two digits per byte, with the last nibble storing the sign. The sign nibbles C, A, F, and E are treated as positive; the sign nibbles B and D are treated as negative. Sign nibbles C and D are referred to as "preferred sign". A sign nibble of F is considered "unsigned," meaning it is neither positive nor negative, though pragmatically you can think of it as positive for arithmetic purposes. +123 is stored in two bytes as x'123C', -456 is stored as x'456D'.

SAS PD 信息指定 PDw.d 其中 w 是字段的宽度(以字节为单位),dem> 是该字段右侧的小数位数.所以 PD3.5 是一个 3 字节的字段(将存储 5 位数字和一个符号),所有 5 位数字都在小数点右侧.

The SAS PD informat specifies PDw.d where w is the width of the field in bytes and d is the number of decimal places to the right within the field. So PD3.5 is a 3 byte field (which would store 5 digits and a sign) with all 5 digits to the right of the decimal point.

要获取 SAS PDw.d 声明的 COBOL 声明...

To obtain the COBOL declaration for a SAS PDw.d declaration...

a = (w * 2) - 1

a = (w * 2) - 1

b = a - d

如果 b = 0
PIC SVd 压缩十进制
其他
PIC S9(b)Vd 压缩十进制

if b = 0
PIC SVd Packed-Decimal
else
PIC S9(b)Vd Packed-Decimal

SAS Z 格式指定 Zw.d 其中 w 是字段的宽度(以字节为单位),dem> 是该字段右侧的小数位数.该字段将在左侧填充零以使其宽度为 w 字节.所以Z6.5指定了一个6字节的输出字段,小数点右边有5个字节.一个字节是小数点本身取的,可惜没有符号的余地,可能是bug,也可能是故意的(可能已知数据都是正数).

The SAS Z format specifies Zw.d where w is the width of the field in bytes and d is the number of decimal places to the right within the field. The field will be padded with zeroes on the left to make it w bytes wide. So Z6.5 specifies a 6 byte output field with 5 bytes to the right of the decimal point. One byte is taken by the decimal point itself, and unfortunately there is no room for the sign, which may be a bug or may be intentional (perhaps all the data is known to be positive).

IP PIC Sv99999 Packed-Decimal.
OP PIC .99999.

当您 MOVE IP TO OP 时,COBOL 将为您完成从压缩十进制到分区十进制的转换.

When you MOVE IP TO OP the conversion from Packed Decimal to Zoned Decimal will be done for you by COBOL.

这篇关于SAS TO COBOL 转换变量声明的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆