DATA data-set-name VIEW= view-name;
The code names a view that the DATA step uses to store the input DATA step view. Where view-name must match
one of the data set names coded on the data statement. (Please note: If you specify additional data sets in the
DATA statement, SAS creates these data sets when the view is processed in a subsequent DATA or PROC step.)
SAMPLE CODE
Suppose you have a large flat file named bigfile.dat stored in the following directory on UNIX:
/mydir/companyx/data. The data from bigfile.dat is to be merged with a smaller permanent SAS data file named
small stored in the same directory. Only the observations common to both files are to be written out to a new
permanent SAS data file named newsmall
Here is the SAS code to accomplish this task without the benefit of using a SAS Data View:
Filename in ‘/mydir/companyx/data/bigfile.dat’;
Data bigfile;
Infile in;
Input @1 key $3.
@4 sales1 9.
@13 sales2 9.
;
libname inout ‘/mydir/companyx/data’;
Data inout.newsmall;
Merge inout.small(in=ins) bigfile(in=inb);
By key;
If ins;
Run;
There is nothing wrong with this code per se. However, the job often fails to run successfully because sufficient
work space is not available at the time the job is executed.
An excellent way to eliminate the need for the large amount of work space is to make use of a SAS data view.
Here is the SAS code to accomplish the same task as above using a SAS data view:
Filename in ‘/mydir/companyx/data/bigfile.dat’;
Data bigfile view=bigfile;
Infile in;
Input @1 key $3.
@4 sales1 9.
@13 sales2 9.
;
libname inout ‘/mydir/companyx/data’;
Data inout.newsmall;
Merge inout.small(in=ins) bigfile(in=inb);
By key;
If ins;
Run;
The only difference in the syntax is the view option coded on the first data step where the temporary SAS data file
“bigfile” is being created.
By creating a SAS data view, the temporary SAS data file “bigfile” is no longer being created in work space.
Therefore, we can now successfully process this job stream because we have eliminated the need for a large
amount of work space where “bigfile” would have been stored prior to being merged with “small”.
No comments:
Post a Comment