How to Access IBM S370/MVS OSIRIS Files with SAS®

Files ending with ".dict" in IRSS's Data Archive are binary copies of files originally written on older IBM mainframe systems running the MVS operating system in a form known as an OSIRIS data dictionary. These files could be used in conjunction with a copy of the data coded in the EBCDIC coding system, rather than ASCII, to create SAS® data files. Since UNC has switched to systems that only can read ASCII coded data, performing this conversion is no longer straightforward. However, using the SAS code below, it is possible to create SAS files using OSIRIS data dictionaries provided you are on a UNIX, Windows or Macintosh computer hooked to the UNC campus network. The code below will access the dictionary and data files using FTP. You do not have to transfer these files to your machine prior to doing the conversion. You must, however, use Version 7 or above of SAS.

You may "cut and paste" this code into the SAS Program Editor window and then make the necessary changes noted below or you may transfer a file containg this code to your machine by holding down your shift key and clicking here and open the file in the SAS Program Editor window or use it as input to a batch SAS job.


******************************************************************
** SAS routine for converting OSIRIS format files to SAS Files  **
**                                                              **
**             Ken Hardy, IRSS, UNC-Chapel Hill                 **
**                       Aug. 6, 1999                           **
**                                                              **
**      WARNING: SPECIAL VERSION FOR USE WITH FILES FROM        **
**                      IRSS DATA ARCHIVE                       **
**                                                              **
**         YOU MUST BE CONNECTED TO UNC's CAMPUS NETWORK !      **
**                                                              **
**            YOU MUST USE SAS VERSION 7 OR HIGHER!             **
**                                                              **
** Many data sets found in IRSS's /pub/irss/icpsr subdirectory  **
** come with a corresponding OSIRIS data dictionary or .dict    **
** file which can be used to directly create a SAS data file.   **
** Variable names in the SAS file will generally match those    **
** in the ICPSR codebook for the data.                          **
**                                                              **
** YOU DO NOT NEED TO FTP THE FILES TO YOUR COMPUTER TO USE     **
** THIS CODE. SAS WILL TAKE CARE OF THE FILE TRANSFER FOR YOU.  **
**                                                              **
** The following SAS code allows you to specify the filenames   **
** for the data (.data) and dictionary (.dict) files, the name  **
** and subdirectory for the SAS file and the SAS file format.   **
** File names must contain complete paths to the appropriate    **
** subdirectory under /pub/irss/icpsr.                          **
**                                                              **
** The code below includes actual data and dict files so that   **
** you may run this code as an example and then change the      **
** filenames etc. below to meet your needs.                     **
****************************************************************** ;

******************************************************************
**     Change filenames etc below after = sign as needed.       **
** You must make changes to lines with a  *<<=CHANGE==<< .      **
** You may want to make changes to lines with *<<=OPTIONAL==<<. **
****************************************************************** ;

***************** Full path and name of data file **************** ;
%LET asciidata=/pub/irss/icpsr/s0013/usel84.data;   *<<=CHANGE==<< ;
               /* ASCII OSIRIS data file name */
               /*  Include complete path if   */
               /*  file not in current subdir.*/

**************** Full path and name of dictionary **************** ;
%LET ebcdicdict=/pub/irss/icpsr/s0013/usel84.dict;  *<<=CHANGE==<< ;
               /* EBCDIC dictionary file name */
               /*  Include complete path if   */
               /*  file not in current subdir.*/

*********************** Name for SAS file ************************* ;
%LET sasname=data84a;                                *<<=CHANGE==<< ;
               /* Name for SAS file           */


%LET library=;                                     *<<=OPTIONAL==<< ;
             /* Subdirectory for SAS file   */
             /* library=; uses current sub- */
             /*  directory.                 */
             /*  Must include a filename    */
             /* (e.g format=~/filename.xpt) */
             /*  if format=XPORT; is used.  */


%LET  format=V8;                                   *<<=OPTIONAL==<< ;
             /* Format for SAS file:        */
             /*  format=V7; for platform V7 */
             /*  format=V6; for platform V6 */
             /*  format=XPORT for V5 export */

*************************************************** ;
**  DO NOT CHANGE ANYTHING BELOW THIS LINE!!!    ** ;
*************************************************** ;

OPTIONS  PAGENO=1 PS=55 MPRINT MACROGEN SYMBOLGEN   ;

** Determine record length of OSIRIS data file.  ** ;
** Input first record and place length in &lrecl.** ;
** Use FTP access method to read .data from IRSS ** ;
** Data Archive using SAS FTP access method.     ** ;

FILENAME in FTP  "&asciidata"
            HOST="ftp.irss.unc.edu"
            USER="anonymous"
            PASS="user@statapps.unc.edu" ;

** Get Record Length of ASCII Data File ** ;
** Place it in MACRO variable -- &lrecl ** ;
DATA _NULL_ ;
INFILE  in  LENGTH=lrecl END=end LRECL=32768 ;
INPUT   ;
IF _N_ = 1 THEN
 CALL SYMPUT("lrecl",TRIM(LEFT(PUT(lrecl,5.)))) ;
ELSE STOP;
run;


** Make a temporary EBCDIC coded data file   **;
** without NL's from ASCII coded .data file. **;
DATA _NULL_                ;
LENGTH  line $  &lrecl     ;
INFILE  in  LRECL=&lrecl   ;
INPUT line $CHAR&lrecl..   ;
FILE  "_ebcdic_" RECFM=F LRECL=&lrecl   ; /* Eliminates NL's */
PUT  line  $EBCDIC&lrecl.. @@ ;
run;

** Convert to SAS file using PROC CONVERT. ** ;
LIBNAME  out &format  "&library"       ;
FILENAME data "_ebcdic_"   ;
** Use FTP access method to read .dict from IRSS ** ;
FILENAME dict FTP   "&ebcdicdict"
            HOST="ftp.irss.unc.edu"
            USER="anonymous"
            PASS="user@statapps.unc.edu" ;

PROC CONVERT OSIRIS=data
             DICT= dict
             OUT=    out.&sasname   ;
run;

** Run PROC CONTENTS on SAS file ** ;
PROC CONTENTS DATA=out.&sasname     ;
TITLE1 "OSIRIS TO SAS FILE CONVERSION";
TITLE2 "Data  file: &asciidata" ;
TITLE3 "Dictionary: &ebcdicdict" ;
TITLE4 "Libname for SAS file is 'OUT'.";
TITLE5 "SAS file name is &sasname.." ;
run;

**    Clear the filerefs                 ** ;
FILENAME data CLEAR ;  FILENAME dict CLEAR  ;

**       Remove temporary file           ** ;
x "rm _ebcdic_" ; x "rem _ebcdic_";
run;