UCLA Academic Technology Services HomeServicesClassesContactJobs
Search

SAS FAQ
How do I read/convert version 6 SAS files/formats using SAS version 8?

How do I read a version 6 data file in SAS version 8?

Say that you have a data file called c:\dissertation\salary6.sd2. Because the extension of the file is .sd2 we know it is a Windows SAS 6.xx file. You can read a file in version 8 much like you would have in version 6, except that you need to explicitly tell SAS that the file is a version 6 file, as shown in the example below. Note the v6 in the example below -- this tells SAS that the libname diss6 will read a version 6.xx file from the directory c:\dissertation.

libname diss6 v6 'c:\dissertation\';
proc contents data=diss6.salary6;
run;
proc print data=diss6.salary6;
run;
We see the output from this program below.  This shows us that we read the file successfully.
The CONTENTS Procedure

Data Set Name: DISS6.SALARY6                              Observations:         2
Member Type:   DATA                                       Variables:            5
Engine:        V6                                         Indexes:              0
Created:       16:53 Thursday, November 16, 2000          Observation Length:   40
Last Modified: 16:53 Thursday, November 16, 2000          Deleted Observations: 0
Protection:                                               Compressed:           NO
Data Set Type:                                            Sorted:               NO
Label:

      -----Engine/Host Dependent Information-----
 <output edited to save space> 
File Name:                  c:\dissertation\salary6.sd2
Release Created:            6.08.00
Host Created:               WIN

-----Alphabetic List of Variables and Attributes-----

#    Variable    Type    Len    Pos
-----------------------------------
1    SAL1996     Num       8      0
2    SAL1997     Num       8      8
3    SAL1998     Num       8     16
4    SAL1999     Num       8     24
5    SAL2000     Num       8     32 

Obs    SAL1996    SAL1997    SAL1998    SAL1999    SAL2000
1      10000      10500      11000      12000      12700
2      14000      16500      18000      22000      29000

How do I convert a version 6 data file to a SAS version 8 data file?

You might want to convert the file c:\dissertation\salary.sd2 (a Windows SAS 6.xx file) to a SAS version 8 file (which you want to call c:\dissertation\salary8.sas7bdat). The extension of the version 8 file will be .sas7bdat because that is the extension that SAS uses for SAS version 8 files. You can do this using the example shown below.
libname diss6 v6 'c:\dissertation\';
data 'c:\dissertation\salary8' ;
  set diss6.salary6;
run;

proc contents data='c:\dissertation\salary8';
run;
proc print data='c:\dissertation\salary8';
run;
We wee the output from this program below.  You can see that the file is now called c:\dissertation\salary8.sas7bdat and you can see that SAS says that the release that created it is version 8 (actually 8.0101M0, i.e., version 8).  You can now read and use this file as a version 8 SAS data file.
The CONTENTS Procedure

Data Set Name: c:\dissertation\salary8                    Observations:         2
Member Type:   DATA                                       Variables:            5
Engine:        V8                                         Indexes:              0
Created:       16:53 Thursday, November 16, 2000          Observation Length:   40
Last Modified: 16:53 Thursday, November 16, 2000          Deleted Observations: 0
Protection:                                               Compressed:           NO
Data Set Type:                                            Sorted:               NO
Label:

        -----Engine/Host Dependent Information-----

 <output edited to save space> 
File Name:                  c:\dissertation\salary8.sas7bdat
Release Created:            8.0101M0
Host Created:               WIN_NT


-----Alphabetic List of Variables and Attributes-----

#    Variable    Type    Len    Pos
-----------------------------------
1    SAL1996     Num       8      0
2    SAL1997     Num       8      8
3    SAL1998     Num       8     16
4    SAL1999     Num       8     24
5    SAL2000     Num       8     32

Obs    SAL1996    SAL1997    SAL1998    SAL1999    SAL2000

 1      10000      10500      11000      12000      12700
 2      14000      16500      18000      22000      29000

How do I convert numerous version 6 SAS data files to SAS version 8?

Say that you had numerous SAS version 6 files in c:\dissertation\ that you wanted to convert to version 8.  For simplicity say that the files were called file1 file2 and file3, but you could have many such files.  The example below shows how you could do the conversion using PROC COPY. Note that the files are read from a directory called c:\dissertation\ and then copied to a directory called c:\dissertation8\ . It is recommended that you use this kind of strategy to copy the files from one location to another.

libname diss6 v6 'c:\dissertation\';
libname diss8 v8 'c:\dissertation8\';
proc copy in=diss6 out=diss8;
  select file1 file2 file3;
run;

How do I convert a version 6 format library to a SAS version 8 format library?

You might want to convert the file c:\diss6\formats.sc2 (a Windows SAS 6.xx format library) to a SAS version 8 format library (which you want to call c:\diss8\formats.sas7bcat. Here is an example showing how you can do that.
libname first v6 "c:\diss6";
libname second v8 "c:\diss8";

proc catalog cat=first.FORMATS;
  copy out=second.FORMATS;
run;
proc format library=second fmtlib; 
run;

We omit the output from this, but the output would show the formats associated with the new (version 8) format library that was created. 

For more information


How to cite this page

Report an error on this page

UCLA Researchers are invited to our Statistical Consulting Services
We recommend others to our list of Other Resources for Statistical Computing Help
These pages are Copyrighted (c) by UCLA Academic Technology Services


The content of this web site should not be construed as an endorsement of any particular web site, book, or software product by the University of California