![]() Chapter Contents |
![]() Previous |
![]() Next |
| DATA |
| Valid: | in a DATA step |
| Category: | File-handling |
| Type: | Declarative |
Syntax |
|
DATA <data-set-name-1
<(data-set-options-1)>>
<. . .data-set-name-n <(data-set-options-n)>> </ VIEW=view-name | PGM=program-name>; |
| DATA PGM=program-name; |
| Arguments |
| See also: | Data Set Options for more information. |
| Featured in: | Creating Multiple Data Files and Using Data Set Options |
| Details |
Usually, the DATA statement specifies at least one data
set name that SAS uses to create an output data set. However, when the purpose
of a DATA step is to write a report or to write an external file, you may
not want to create an output data set. Using the keyword _NULL_ as the data
set name causes SAS to execute the DATA step without writing observations
to a data set. See Creating a Custom Report.
| Action | Example | |
|---|---|---|
| Creating and storing |
data sales2/pgm=salerpt; |
|
| Executing |
data pgm=salerpt; |
|
| Examples |
data error (keep=subject date weight)
fitness(label='Exercise Study'
rename=(weight=pounds));The ERROR data set contains three
variables. SAS assigns a label to the FITNESS data set and renames the variable weight to pounds.
This DATA step creates an input DATA step view instead of a SAS data file:
libname ourlib 'SAS-data-library'; data ourlib.test / view=ourlib.test; set ourlib.fittest; tot=sum(of score1-score10); run;
libname ourlib 'SAS-data-library-1'; libname theirlib 'SAS-data-library-2'; data theirlib.test scoretot / view=theirlib.test; set ourlib.fittest; tot=sum(of score1-score10); run;SAS does not create the data file SCORETOT until a subsequent DATA or PROC step processes the view THEIRLIB.TEST.
The first DATA step produces a stored compiled program named STORED.SALESFIG:
libname in 'SAS-data-library-1 '; libname stored 'SAS-data-library-2 '; data salesdata / pgm=stored.salesfig; set in.sales; qtr1tot=jan+feb+mar; run;SAS creates the data set SALESDATA when it executes the stored compiled program STORED.SALESFIG.
data pgm=stored.salesfig; run;
data sales;
input dept : $10. jan feb mar;
datalines;
shoes 4344 3555 2666
housewares 3777 4888 7999
appliances 53111 7122 41333
;
data _null_;
set sales;
qtr1tot=jan+feb+mar;
put 'Total Quarterly Sales: '
qtr1tot dollar12.;
run;
| See Also |
![]() Chapter Contents |
![]() Previous |
![]() Next |
![]() Top of Page |
Copyright © 1999 by SAS Institute Inc., Cary, NC, USA. All rights reserved.