SAS Institute. The Power to Know

FOCUS AREAS

Hot Topics

Related Links

SAS®9 Compatibility

Migration

Best Practices for Compatibility

These coding practices and example code can facilitate compatibility.

Helpful Language Elements

The following coding practices maximize your control over cross-release compatibility.

MSGLEVEL=
Setting the system option MSGLEVEL=I generates a log note with useful information about index usage, merge processing, and sort utilities, along with standard notes, warnings, and error messages. You might want to know, for example, whether a file is being processed with CEDA. Beginning with SAS 9.1.3 Service Pack 4, you get this behavior even if you do not specify MSGLEVEL=I.

VALIDVARNAME=
Setting the system option VALIDVARNAME=V6 truncates long variable names. Similarly, VALIDVARNAME=V7 forces appropriate Version 7 naming behavior.

VALIDFMTNAME=
Setting the system option VALIDFMTNAME=FAIL causes an error message when a long format or informat name is used, which is useful for Version 7 or 8 behavior. If a long format name is used in Version 6, processing fails.

V6CREATEUPDATE=
The V6CREATEUPDATE= system option controls and monitors the behavior of SAS when an attempt is made to create or update a Version 6 data set.

Encoding language elements
override the session encoding. Understanding encoding can be important when you exchange data with others. When you use PROC MIGRATE, a migrated data set takes on the data representation and encoding attributes of the target library. See the SAS NLS (National Language Support) User's Guide for information about encoding and transcoding.

Determining Data Representation and Encoding

SAS performs best when accessing native files. When a file's data representation and character encoding are compatible with those of the current session, then the file is considered native. If you work with files created under incompatible operating environments, then you need a way to quickly learn the data representation and character encoding of a data set and compare it to those of the current session.

Interpreting PROC CONTENTS Output for a Version 7 or Later SAS File

In SAS®9, the CONTENTS procedure writes out more information about data file attributes of Version 7 and later files. In the CONTENTS output, "Data Representation" lists the environments on which the file can be processed as a native file with no processing limitations. In SAS®9, the value is improved with _32 or _64 to designate 32-bit or 64-bit architecture. Also new in SAS®9 is the "Encoding" attribute, which lists the file's character encoding (see SAS National Language Support (NLS): User's Guide in the online documentation).

In the following example, the data representation values are all 64-bit UNIX operating environments. The encoding is latin1. In this example, if you are currently running SAS®9 on any of the listed UNIX operating environments under latin1 session encoding, then you are dealing with a native data file and you have full processing capabilities. If this is the case, then you do not need to migrate this file to SAS®9 format unless you want to use one of the new SAS®9 file features. If you determine that the file is not native, then you can read the CEDA processing topic to learn what processing is supported.

                                  The SAS System                                1

                               The CONTENTS Procedure

Data Set Name       HEALTH.OXYGEN                          Observations         31
Member Type         DATA                                   Variables            7
Engine              V9                                     Indexes              0
Created             Wednesday, May 07, 2003 10:03:30       Observation Length   56
Last Modified       Wednesday, May 07, 2003 10:03:30       Deleted Observations 0
Protection                                                 Compressed           NO
Data Set Type                                              Sorted               NO
Label
Data Representation HP_UX_64, RS_6000_AIX_64, SOLARIS_64, HP_IA64
Encoding            latin1  Western ( ISO )

Using PROC CONTENTS for a Version 7 or Later SAS File

In a SAS®9 session, PROC CONTENTS together with the ODS OUTPUT statement and ATTRIBUTES= can write out the data representation and encoding values. Run the code first for the current session and then for existing files.

  1. Submit the following code in a SAS®9 session:
       data check_session;x=1;
       run;
    
       ods output attributes=atr1(keep=label1 cvalue1
           where=(label1 in ('Data Representation', 'Encoding')));
       ods listing close;
       proc contents data=check_session;
       run;
    
       ods listing;
       proc print data=atr1;
       run;
    
    And you get handy output that makes the current session's data representation and encoding values easy to see:
       Obs    Label1                 cValue1
    
        1     Data Representation    MVS_32
        2     Encoding               open_ed-1047  Western (OpenEdition)
    
  2. Now, to output the data representation and encoding values of an existing data set, omit the DATA step. On the PROC CONTENTS statement, replace CHECK_SESSION with the data set's name.

Using PROC CONTENTS for a Version 6 SAS File

For a Version 6 file, the data representation and encoding values are always returned as DEFAULT, so you cannot use the same method as you would for a Version 7 or 8 file. Instead use example code like the following (which works for Version 6, 7, and 8 files) to write out the value of the "Host Created" attribute. Run the code first for the current session and then for existing files.

  1. Submit the following code in a SAS®9 session. This code is supported in all SAS 8 and 9 operating environments except z/OS.
       data test;x=1;run;
    
       ods output EngineHost=eng(keep=label1 cvalue1
           where=(label1='Host Created'));
       ods listing close;
       proc contents data=test;run;
       ods listing;
    
       proc print data=eng;run;
    
    The code creates a simple test data set and then writes out its Host Created value for the current session. The example output says the file was created under SunOS:
       Obs       Label1       cValue1
         1     Host Created    SunOS
    
  2. To output the Host Created of an existing data set, omit the DATA step. On the PROC CONTENTS statement, replace TEST with the data set's name.