Creating or Changing a SAS File's Format

Creating a SAS File in a Foreign Format

By default, new SAS files or SAS libraries that you create using the DATA step or the LIBNAME statement are created in the native format of the source computer. For example, under Windows, a new data set is created in a Windows native format. However, you can override the default and create a data set in a foreign format. For example, under Windows, you could create a new data set in a foreign format, such as a UNIX data representation.

Example: Creating a Foreign Format Using the OUTREP= Option in the DATA Step

In order to create a SAS file in a foreign format for a supported member type, use the OUTREP= option in the DATA step. The OUTREP= option applies the foreign format to the specified data set.
In this example, assume that the native format is a Windows representation, which is being overridden by the foreign format, HP_UX_64:
data chem.grades (outrep=HP_UX_64);
  input student $ test1 test2 final;
  datalines;
Fred 66 80 70
Wilma 97 91 98
  run;
In this example, the data set GRADES is created in the foreign format, HP_UX_64.
For supported values for the OUTREP= option, see the LIBNAME Statement in SAS Statements: Reference or the OUTREP= option in SAS Data Set Options: Reference.

Changing a SAS File to a Foreign Format

You can also change the file's native format to a foreign format by using the LIBNAME statement and the OUTREP= option along with the COPY procedure and the NOCLONE option at the source computer or at the target computer.
At the source computer, you could change the file's native format to a foreign format, and then transfer the file to the target computer.
Alternatively, at the source computer, you could transfer the file in its native format to the target computer. At the target computer, you could then change the file's native format to the foreign format that is used at the target computer.

Example: Changing a File's Format Using the OUTREP= Option in the LIBNAME Statement and the NOCLONE Option in PROC COPY

Here is the process to change a SAS file's native format to a foreign format for a supported member type:
Note: The file format of MDDB files cannot be changed. CEDA supports MDDB files for read-only access.
  1. Use a LIBNAME statement and the OUTREP= option to point to the file that will be created in foreign format.
  2. Use a LIBNAME statement to point to the file that is in native format.
  3. Use the COPY procedure to copy the file in native format to the file in foreign format. Also, use the NOCLONE option, which chooses the data representation of the file in foreign format instead of the file in native format.
Here is an example:
libname target 'path-to-target-library' outrep=HP_UX_64;
libname source 'path-to-source-library';
proc copy in=source out=target noclone memtype=data;
run;
In this example, the library of data sets in Windows native format is copied to a library of data sets in HP_UX_64 foreign format.
For supported values of the OUTREP= option, see the LIBNAME Statement in SAS Statements: Reference or the OUTREP= option in SAS Data Set Options: Reference. . For details about the NOCLONE option, see the COPY procedure in the Base SAS Procedures Guide.

Example: Verifying the Changed File's Format in the SAS Log at the Source Computer

You view the SAS log at the source computer that runs the native Windows operating environment to verify that the SAS file was changed to the HP_UX_64 foreign format.
Data Representation Specified in the SAS Log
The SAS System       10:15 Friday, December 19, 2003   1

                                     The CONTENTS Procedure

     Data Set Name     WORK.GRADES                          Observations        
 1
     Member Type       DATA                                 Variables           
 4
     Engine            V9                                   Indexes             
 0
     Created           11:03 Friday, December 19, 2003      Observation Length  
 32
     Last Modified     11:03 Friday, December 19, 2003      Deleted Observations
 0
     Protection                                             Compressed          
 NO
     Data Set Type                                          Sorted              
 NO
     Label
     Data Representation  HP_UX_64, RS_6000_AIX_64, SOLARIS_64, HP_IA_64
1 
     Encoding          latin1  Western (ISO)
                   

                               Engine/Host Dependent Information

       Data Set Page Size          4096
       Number of Data Set Pages    1
       First Data Page             1
       Max Obs per Page            126
       Obs in First Data Page      1
       Number of Data Set Repairs  0
       File Name                   C:\TEMP\SAS Temporary
Files\_TD228\grades.sas7bdat
       Release Created             9.0000M0
       Host Created                WIN_NT  2 


                        Alphabetic List of Variables and Attributes

                               #    Variable    Type    Len

                               4    final       Num       8
                               1    student     Char      8
                               2    test1       Num       8
                               3    test2       Num       8
1The data set is represented in HP_UX_64 format, which is foreign to the native Windows environment.
2The native format is WIN_NT.