|
SAS®9 Compatibility
|
These coding practices and example code can facilitate compatibility.
The following coding practices maximize your control over cross-release compatibility.
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.
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 )
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.
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)
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.
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