Creates one or more data sets, each of which contains the data in the hash object.
Applies to: | Hash object |
specifies whether the method succeeded or failed.
specifies the name of the hash object.
specifies the name of the output data set.
specifies a data set option.
ordered: 'yes'
or ordered: 'ascending'
argument
tag in the DECLARE statement or the _NEW_ operator when you instantiate
the hash object, then the data items are written to the data set in
ascending key-value order. If you use the ordered: 'descending'
argument
tag in the DECLARE statement or the _NEW_ operator when you instantiate
the hash object, then the data items are written to the data set in
descending key-value order. If you do not use the ordered
argument
tag, the order is undefined.
data x;
do i = 1 to 20;
output;
end;
run;
/* Using the WHERE option. */
data _null_;
length i 8;
dcl hash h(dataset:'x');
h.definekey(all: 'y');
h.definedone();
h.output(dataset: 'out (where =( i < 8))');
run;
This example uses the RENAME data set option to
rename the variable J to K for the output data set named OUT. data x;
do i = 1 to 20;
output;
end;
run;
/* Using the RENAME option. */
data _null_;
length i j 8;
dcl hash h(dataset:'x');
h.definekey(all: 'y');
h.definedone();
h.output(dataset: 'out (rename =(i=k))');
run;
For a list of data set options, see SAS Data Set Options: Reference.
data _null_; length k 8; length d $10; declare hash h2(); declare hash h(ordered: 'y'); h.defineKey('k'); h.defineData('k', 'd', 'h2'); h.defineDone(); k = 99; d = 'abc'; h.add(); k = 199; d = 'def'; h.add(); h.output(dataset:'work.x'); run;
data astro;
input obj $1-4 ra $6-12 dec $14-19;
datalines;
M31 00 42.7 +41 16
M71 19 53.8 +18 47
M51 13 29.9 +47 12
M98 12 13.8 +14 54
M13 16 41.7 +36 28
M39 21 32.2 +48 26
M81 09 55.6 +69 04
M100 12 22.9 +15 49
M41 06 46.0 -20 44
M44 08 40.1 +19 59
M10 16 57.1 -04 06
M57 18 53.6 +33 02
M3 13 42.2 +28 23
M22 18 36.4 -23 54
M23 17 56.8 -19 01
M49 12 29.8 +08 00
M68 12 39.5 -26 45
M17 18 20.8 -16 11
M14 17 37.6 -03 15
M29 20 23.9 +38 32
M34 02 42.0 +42 47
M82 09 55.8 +69 41
M59 12 42.0 +11 39
M74 01 36.7 +15 47
M25 18 31.6 -19 15
;
run;
data _null_;
if _N_ = 1 then do;
length obj $10;
length ra $10;
length dec $10;
/* Read ASTRO data set as ordered */
declare hash h(hashexp: 4, dataset:"work.astro", ordered: 'yes');
/* Define variables RA and OBJ as key and data for hash object */
h.defineKey('ra');
h.defineData('ra', 'obj');
h.defineDone();
/* avoid uninitialized variable notes */
call missing(ra, obj);
end;
/* Create output data set from hash object */
rc = h.output(dataset: 'work.out');
run;
proc print data=work.out;
var ra obj;
title 'Messier Objects Sorted by Right-Ascension Values';
run;