Informats. SAS Informats under OpenVMS. Reading Binary Data CHAPTER 15

Similar documents
Formats. SAS Formats under OpenVMS. Writing Binary Data CHAPTER 13

Formats. SAS Formats under OS/2. Writing Binary Data CHAPTER 13

Informats. Informats in the CMS Environment. Considerations for Using Informats under CMS. EBCDIC and Character Data CHAPTER 15

Informats. Informats Under UNIX. HEXw. informat. $HEXw. informat. Details CHAPTER 13

Formats. Formats Under UNIX. HEXw. format. $HEXw. format. Details CHAPTER 11

Data Representation. Variable Precision and Storage Information. Numeric Variables in the Alpha Environment CHAPTER 9

Using Cross-Environment Data Access (CEDA)

CHAPTER 13 Importing and Exporting External Data

Using Data Transfer Services

Introduction. LOCK Statement. CHAPTER 11 The LOCK Statement and the LOCK Command

Chapter 28 Saving and Printing Tables. Chapter Table of Contents SAVING AND PRINTING TABLES AS OUTPUT OBJECTS OUTPUT OBJECTS...

APPENDIX 2 Customizing SAS/ASSIST Software

from the source host, use the FTP put command to copy a file from the source host to the target host.

Chapter 7 File Access. Chapter Table of Contents

Permission Program. Support for Version 6 Only. Allowing SAS/SHARE Client Access to SAS Libraries or Files CHAPTER 40

Chapter 3 Managing Results in Projects. Chapter Table of Contents

Storing and Reusing Macros

SAS. IT Service Level Management 2.1: Migration Documentation

SAS/ASSIST Software Setup

Using SAS Files. Introduction CHAPTER 5

Graphics. Chapter Overview CHAPTER 4

OpenVMS Operating Environment

Routing the SAS Log and SAS Procedure Output

SAS I/O Engines. Definition. Specifying a Different Engine. How Engines Work with SAS Files CHAPTER 36

Macro Facility. About the Macro Facility. Automatic Macro Variables CHAPTER 14

The EXPLODE Procedure

QUEST Procedure Reference

Chapter 6 Creating Reports. Chapter Table of Contents

SAS Support for TELNET on Windows

Chapter 25 PROC PARETO Statement. Chapter Table of Contents. OVERVIEW SYNTAX SummaryofOptions DictionaryofOptions...

DBLOAD Procedure Reference

Using the SQL Editor. Overview CHAPTER 11

SAS Catalogs. Definition. Catalog Names. Parts of a Catalog Name CHAPTER 32

Chapter 23 Animating Graphs. Chapter Table of Contents ANIMATING SELECTION OF OBSERVATIONS ANIMATING SELECTED GRAPHS...347

SAS File Management. Improving Performance CHAPTER 37

The GTESTIT Procedure

SYSTEM 2000 Essentials

Creating and Executing Stored Compiled DATA Step Programs

Chapter 2 User Interface Features. networks Window. Drawing Panel

CHAPTER 7 Using Other SAS Software Products

Data Set Options. Specify a data set option in parentheses after a SAS data set name. To specify several data set options, separate them with spaces.

External Files. Definition CHAPTER 38

The TRANTAB Procedure

Using Dynamic Data Exchange

APPENDIX 4 Migrating from QMF to SAS/ ASSIST Software. Each of these steps can be executed independently.

CS 265. Computer Architecture. Wei Lu, Ph.D., P.Eng.

SCL Arrays. Introduction. Declaring Arrays CHAPTER 4

Alternative ODS HTML Statements for Running Examples in Different Operating Environments

unused unused unused unused unused unused

Locking SAS Data Objects

The correct bibliographic citation for this manual is as follows: SAS Institute Inc Proc EXPLODE. Cary, NC: SAS Institute Inc.

UNIX Platform Error Messages

Introduction. CHAPTER 3 Working in the SAS Windowing Environment

Examples That Use Remote Objecting

Defining Your Data Sources

Optimizing System Performance

Windows: SPX Access Method

OS/390 Platform Examples

Chapter 27 Saving and Printing Graphics

Tasks Menu Reference. Introduction. Data Management APPENDIX 1

Choosing the Right Procedure

OS/2: SPX Access Method

The STANDARD Procedure

Chapter 25 Editing Windows. Chapter Table of Contents

The TIMEPLOT Procedure

CHAPTER 7 Examples of Combining Compute Services and Data Transfer Services

Using the SAS/ACCESS Interface to IMS-DL/I DATA Step Interface

SAS Workflow Manager 2.2: Administrator s Guide

Number Systems and Binary Arithmetic. Quantitative Analysis II Professor Bob Orr

Licensing SAS DataFlux Products

Chapter 13 Multivariate Techniques. Chapter Table of Contents

IT 1204 Section 2.0. Data Representation and Arithmetic. 2009, University of Colombo School of Computing 1

The GSLIDE Procedure. Overview. About Text Slides CHAPTER 27

Number Systems. Decimal numbers. Binary numbers. Chapter 1 <1> 8's column. 1000's column. 2's column. 4's column

COMP2611: Computer Organization. Data Representation

The SERVER Procedure. Introduction. Syntax CHAPTER 8

Customizing Your SAS Session

Overview. CHAPTER 2 Using the SAS System and SAS/ ASSIST Software

Loading Data. Introduction. Understanding the Volume Grid CHAPTER 2

SAS Web Infrastructure Kit 1.0. Overview

Introduction to the OpenVMS Operating Environment

Inf2C - Computer Systems Lecture 2 Data Representation

Floating-point Arithmetic. where you sum up the integer to the left of the decimal point and the fraction to the right.

Chapter 14 Introduction to the FACTEX Procedure

Numeric Variable Storage Pattern

Enterprise Miner Software: Changes and Enhancements, Release 4.1

Introduction. Getting Started with the Macro Facility CHAPTER 1

What Is a Communications Access Method? CHAPTER 1 Using Communications Access Methods

SAS/ACCESS Data Set Options

Getting Started with SAS Factory Miner 14.2

Handling Exceptions. Introduction. Using the Program Halt Handler CHAPTER 10

Real Numbers finite subset real numbers floating point numbers Scientific Notation fixed point numbers

SAS Data Libraries. Definition CHAPTER 26

Expressions. Definitions CHAPTER 12

Introduction to MDDBs

Project 1: Creating and Using Multiple Artboards

SAS Data Integration Studio 3.3. User s Guide

UNIT 7A Data Representation: Numbers and Text. Digital Data

Introduction. Understanding SAS/ACCESS Descriptor Files. CHAPTER 3 Defining SAS/ACCESS Descriptor Files

Chapter 9 Selected Examples. Queues with Reneging

Transcription:

321 CHAPTER 15 Informats SAS Informats under OpenVMS 321 Reading Binary Data 321 SAS Informats under OpenVMS A SAS informat is an instruction or template that the SAS System uses to read data values into a variable. Most SAS informats are described completely in SAS Language Reference: Dictionary. The informats that are described here have behavior that is specific to the SAS System under OpenVMS. Many of the SAS informats that have details that are specific to the OpenVMS operating environment are used to read binary data. For more information, see Reading Binary Data on page 321. Reading Binary Data Different computers store numeric binary data in different forms. IBM 370 and Helett-Packard 9000 computers store bytes in one order. Microcomputers that are IBM compatible and some computers manufactured by al Equipment Corporation store bytes in a different order called byte-reversed. Binary data that are stored in one order cannot be read by a computer that stores binary data in the other order. When you are designing SAS applications, try to anticipate ho your data ill be read and choose your formats and informats accordingly. The SAS System provides to sets of informats for reading binary data and corresponding formats for riting binary data. 3 The IB.d, PD.d, PIB.d, and RB.d informats and formats read and rite in native mode, that is, using the byte-ordering system that is standard for the machine. 3 The S370FIB.d, S370FPD.d, S370FRB.d, and S370FPIB.d informats and formats read and rite according to the IBM 370 standard, regardless of the native mode of the machine. These informats and formats allo you to rite SAS programs that can be run in any SAS environment, regardless of ho numeric data are stored. If a SAS program that reads and rites binary data runs on only one type of machine, you can use the native mode informats and formats. Hoever, if you ant to rite SAS programs that can be run on multiple machines using different byte-storage

322 HEX. 4 Chapter 15 systems, use the IBM 370 formats and informats. The purpose of the IBM 370 informats and formats is to enable you to rite SAS programs that can be run in any SAS environment, no matter hat standard you use for storing numeric data. For example, suppose you have a program that rites data ith the PIB.d format. You execute the program on a microcomputer so that the data are stored in byte-reversed mode. Then you run another SAS program on the microcomputer that uses the PIB.d informat to read the data. The data are read correctly because both of the programs are run on the microcomputer using byte-reversed mode. Hoever, you cannot upload the data to a Helett-Packard 9000-series machine and read the data correctly because they are stored in a form native to the microcomputer but foreign to the Helett-Packard 9000. To avoid this problem, use the S370FPIB.d format to rite the data; even on the microcomputer, this causes the data to be stored in IBM 370 mode. Then read the data using the S370FPIB.d informat. Regardless of hat type of machine you use hen reading the data, they are read correctly. HEX. Converts hexadecimal positive binary values to either integer-binary (fixed-point) or real-binary (floating-point) values Category: numeric Width range: 1to16 Default idth: 8 OpenVMS specifics: character-encoding system HEX. specifies the field idth of the input value. If you specify a value of 1 through 15, the input hexadecimal value is converted to an fixed-point number. If you specify 16 for the value, the input hexadecimal value is converted to a floating-point number. Under OpenVMS, the hexadecimal format of the number is stored in representation. For more information about OpenVMS floating-point representation, see Architecture Reference Manual for Alpha and Architecture Reference Manual for VAX.

Informats 4 IB.d 323 3 Informats: HEX. insas Language Reference: Dictionary and $HEX. on page 323 3 Format: HEX. on page 264 $HEX. Converts hexadecimal data to character data Category: character Width range: 1 to 32767 Default idth: 2 OpenVMS specifics: character-encoding system $HEX. specifies idth of the input value. The $HEX. informat is similar to the HEX. informat. The $HEX. informat converts character values that are stored as the hexadecimal equivalent of character codes to the corresponding character values. The conversion is based on the character-encoding system. In the system, the conversion for 8-bit hexadecimal input (x 80 and above) is for the Multinational Set, hich includes national characters such as Ä and ß. For more information about the Multinational Set, see Guide to Using OpenVMS. 3 Informats: $HEX. insas Language Reference: Dictionary and HEX. on page 322 3 Format: $HEX. on page 265 IB.d Reads integer-binary (fixed-point) values Language element: informat

324 PD.d 4 Chapter 15 Category: numeric Width range: 1to8 Default idth: 4 Decimal range: 0to10 OpenVMS specifics: native tos-complement notation IB.d specifies the idth of the input field. d optionally specifies the poer of 10 by hich to divide the input value. If you specify d, the IB.d informat divides the input value by the 10 d value. SAS uses the d value, even if the input data contain decimal points. The IB.d informat reads integer-binary (fixed-point) values that are represented in the OpenVMS tos-complement notation. For information about OpenVMS native fixed-point values, see Architecture Reference Manual for Alpha and Architecture Reference Manual for VAX. 3 Informat: IB.d in SAS Language Reference: Dictionary 3 Format: IB.d on page 265 3 Reading Binary Data on page 321 PD.d Reads packed decimal data Category: numeric Width range: 1to16 Default idth: 1 Decimal range: 0to10 OpenVMS specifics: Ho values are interpreted as negative or positive PD.d

Informats 4 PIB.d 325 specifies the idth of the input field. d optionally specifies the poer of 10 by hich to divide the input value. If you specify d, the PD.d informat divides the input value by the 10 d value. If the data contain decimal points, then SAS ignores the d value. Under OpenVMS, the least significant 4 bits of the least significant byte in the PD value are interpreted as follos: 3 If the hexadecimal number in the 4 bits is D or F, then the value is interpreted as negative. 3 If the hexadecimal number in the 4 bits is C, then the value is interpreted as positive. 3 Informat: PD.d in SAS Language Reference: Dictionary 3 Format: PD.d on page 266 3 Reading Binary Data on page 321 PIB.d Reads positive integer-binary (fixed-point) values Category: numeric Width range: 1to8 Default idth: 1 Decimal range: 0to10 OpenVMS specifics: native integer-binary values; byte reversal PIB.d specifies the idth of the input field. d optionally specifies the poer of 10 by hich to divide the input value. If you specify d, the PIB.d informat divides the input value by the 10 d value. SAS uses the d value even if the input data contain decimal points.

326 RB.d 4 Chapter 15 Under OpenVMS, the PIB informat reads native integer-binary values. Hoever, this informat ignores the negativity of data in tos-complement notation and reads it as positive. For more information about OpenVMS native fixed-point values, see Architecture Reference Manual for Alpha and Architecture Reference Manual for VAX. 3 Informat: PIB.d in SAS Language Reference: Dictionary 3 Format: PIB.d on page 267 3 Reading Binary Data on page 321 RB.d Reads real-binary (floating-point) data Category: numeric Width range: 2to8 Default idth: 4 Decimal range: 0to10 OpenVMS specifics: native floating-point representation RB.d specifies the idth of the input field. d optionally specifies the poer of 10 by hich to divide the input value. If you specify d, the RB.d informat divides the input value by the 10 d value. SAS uses the d value even if the input data contain decimal points. The RB.d informat reads numeric data that are stored in native real-binary (floating-point) notation. Numeric data for scientific calculations are often stored in floating-point notation. (The SAS System stores all numeric values in floating-point notation.) A floating-point value consists of to parts: a mantissa that gives the value and an exponent that gives the value s magnitude. It is usually impossible to key in floating-point binary data directly from a terminal, but many programs rite floating-point binary data. Use caution if you are using the RB.d informat to read floating-point data created by programs other than the SAS System because the RB.d informat is designed to read only double-precision data.

Informats 4 RB.d 327 Since the RB.d informat is designed to read only double-precision data, it supports idths of less than 8 bytes only for those applications that truncate numeric data for space-saving purposes. RB4. does not expect a single-precision number that is truncated to 4 bytes. External programs such as those ritten in C and FORTRAN can produce only single- or double-precision floating-point numbers. No length other than 4 or 8 bytes is alloed. The RB.d informat allos a length of 3 through 8 bytes, depending on the storage you need to save. The FLOAT4. informat has been created to read a single-precision, floating-point number. If you read the hexadecimal notation 3F800000ith FLOAT4., the result is a value of 1. To read data created by a C or FORTRAN program, you need to decide on the proper informat to use. If the floating-point numbers require an 8-byte idth, you should use the RB8. informat. If the floating-point numbers require a 4-byte idth, you should use FLOAT4. For more information about OpenVMS floating-point representation, see Architecture Reference Manual for Alpha and Architecture Reference Manual for VAX. Examples Example 1: Single- vs. Double-Precision Representation Consider ho the value of 1 is represented in single-precision and double-precision notation. For single-precision, the hexadecimal representation of the 4 bytes of data is 3F800000. For double-precision, the hexadecimal representation is 3FF0000000000000. The digits at the beginning of the data are different, indicating a different method of storing the data. Example 2: Reading External Data #include <stdio.h> Consider this C example: main() { FILE *fp; float x[3]; fp = fopen( test.dat, b ); x[0] = 1; x[1] = 2; x[2] = 3; frite((char *)x,sizeof(float),3,fp); fclose(fp); } The file TEST.DAT ill contain, in hexadecimal notation, 3f8000004000000040400000.

328 VMSTIME. 4 Chapter 15 3 Informat: RB.d in SAS Language Reference: Dictionary 3 Format: RB.d on page 268 3 Reading Binary Data on page 321 VMSTIME. Converts an 8-byte binary value that is in OpenVMS date and time format to a SAS date-time value Category: date and time Width range: 8 Default idth: 8 OpenVMS specifics: All aspects are host-specific VMSTIME. The VMSTIME. informat is specific to the OpenVMS operating environment. You cannot specify a idth ith this informat; the idth is alays 8 bytes. OpenVMS date and time values that are read in ith the VMSTIME. informat retain precision up to 1/100 of a second, even though the SAS System cannot display anything less than hole seconds. If you later use the VMSTIMEF. format to rite out the date-time value, the precision is retained. 3 Format: VMSTIMEF. on page 271 VMSZN.d Reads VMS zoned numeric data Category: numeric Width range: 1to32 Default idth: 1 OpenVMS specifics: All aspects are host-specific

Informats 4 VMSZN.d 329 VMSZN.d specifies the idth of the output field. d optionally specifies the number of digits to the right of the decimal point in the numeric value. The VMSZN.d informat is similar to the ZD.d informat. Both read a string of digits, and the last digit is a special character denoting the magnitude of the last digit and the sign of the entire number. The difference beteen the VMSZN.d informat and the ZD.d informat is in the special character used for the last digit. The folloing table shos the special characters used by the VMSZN.d informat. Desired Special Desired Special 0 0-0 p 1 1-1 q 2 2-2 r 3 3-3 s 4 4-4 t 5 5-5 u 6 6-6 v 7 7-7 8 8-8 x 9 9-9 y Data formatted using the VMSZN.d informat are strings. Examples If you format the string 1234 using the VMSZN.d informat in the folloing SAS input @1 vmszn4.; the result is 1234. If you format the string 123t using the VMSZN.d informat in the folloing SAS input @1 vmszn4.; the result is -1234.

330 ZD.d 4 Chapter 15 3 Informats: ZD.d in SAS Language Reference: Dictionary and ZD.d on page 330 3 Format: VMSZN.d on page 271 ZD.d Reads zoned decimal data Category: numeric Width range: 1to32 Default idth: 1 OpenVMS specifics: the last byte includes the sign ZD.d specifies the idth of the input field. d optionally specifies the poer of 10 by hich to divide the input value. If you specify d, the ZD.d informat divides the input value by the 10 d value. If the data contain decimal points, then SAS ignores the d value. The ZD.d informat accepts true zoned decimal, trailing numeric strings ith the overpunch format; numeric strings of the form that is read by the standard numeric informat; and hybrid strings. A hybrid string is a zoned decimal string that has an explicit sign. To achieve the same results as the Release 6.06 implementation of the ZD.d informat, use the ZDV.d informat. A zoned decimal, or trailing numeric string ith overpunch format, is a character string consisting of digits. The last character of the string is a special character that specifies both the value of the last digit and the sign of the entire number. The special characters are listed in the folloing table. 0 { -0 } 1 A -1 J 2 B -2 K

Informats 4 ZD.d 331 3 C -3 L 4 D -4 M 5 E -5 N 6 F -6 O 7 G -7 P 8 H -8 Q 9 I -9 R The data formatted using the ZD.d informat are strings. Examples If you format the string 123{ using ZD.d informat in the folloing SAS input i zd4.; the result is 1230. If you format the string 123} using the ZD.d informat in the folloing SAS input i zd4.; the result is -1230. If you format the string 1230 using the ZD.d informat in the folloing SAS input i zd4.; the result is 1230. If you format the string -1230 using the ZD.d informat in the folloing SAS input i zd5.; the result is -1230. If you format the string +123{ using the ZD.d informat in the folloing SAS input i zd5.; the result is 1230.

332 ZDV.d 4 Chapter 15 3 Informats: ZD.d in SAS Language Reference: Dictionary and ZDV.d on page 332 ZDV.d Reads zoned decimal data Category: Numeric Width range: 1to32 Default idth: 1 OpenVMS specifics: All aspects are host-specific ZDV.d specifies the idth of the input field. d optionally specifies the poer of 10 by hich to divide the input value. If you specify d, the ZDV.d informat divides the input value by the 10 d value. If the data contain decimal points, then SAS ignores the d value. In Release 6.07 of the SAS System, the ZDV.d informat replaced the ZD.d informat ith one change: although the string must be a true trailing numeric ith overpunch format, it no longer needs to be right-justified ithin its field. Trailing blanks are trimmed before the number is converted. A zoned decimal, or trailing numeric string ith overpunch format, is a character string that consists of digits. The last character of the string is a special character that specifies both the value of the last digit and the sign of the entire number. The special characters are the same as those that are documented for the ZD.d informat, as shon in the folloing table. 0 { -0 } 1 A -1 J 2 B -2 K 3 C -3 L 4 D -4 M

Informats 4 ZDV.d 333 5 E -5 N 6 F -6 O 7 G -7 P 8 H -8 Q 9 I -9 R The data formatted using the ZDV.d informat are strings. Examples If you format the string 123{ using ZDV.d informat in the folloing SAS input i zd4.; the result is 1230. If you format the string 123} using the ZDV.d informat in the folloing SAS input i zd4.; the result is -1230. If you format the string 1230 using the ZDV.d informat in the folloing SAS input i zd4.; the result is invalid data. If you format the string -1230 using the ZDV.d informat in the folloing SAS input i zd5.; the result is invalid data. 3 Informats: ZD.d in SAS Language Reference: Dictionary and ZD.d on page 330

334 ZDV.d 4 Chapter 15

The correct bibliographic citation for this manual is as follos: SAS Institute Inc., SAS Companion for the OpenVMS Environment, Version 8, Cary, NC: SAS Institute Inc., 1999. 518 pp. SAS Companion for the OpenVMS Environment, Version 8 Copyright 1999 by SAS Institute Inc., Cary, NC, USA. 1 58025 526 4 All rights reserved. Printed in the United States of America. No part of this publication may be reproduced, stored in a retrieval system, or transmitted, by any form or by any means, electronic, mechanical, photocopying, or otherise, ithout the prior ritten permission of the publisher, SAS Institute Inc. U.S. Government Restricted Rights Notice. Use, duplication, or disclosure of the softare by the government is subject to restrictions as set forth in FAR 52.227 19 Commercial Computer Softare-Restricted Rights (June 1987). 1st printing, October 1999 SAS and all other SAS Institute Inc. product or service names are registered trademarks or trademarks of SAS Institute Inc. in the USA and other countries. indicates USA registration. Other brand and product names are registered trademarks or trademarks of their respective companies. The Institute is a private company devoted to the support and further development of its softare and related services. SAS Institute Inc., SAS Campus Drive, Cary, North Carolina 27513.