General form, GENNUM=
data set option:
GENNUM=n
n
specifies a particular
historical version of a data set:
|
proc print data=year; run;
proc print data=year(gennum=4); /*absolute reference*/ run;
proc print data=year(gennum=-1); /*relative reference*/ run;
proc contents data=year(gennum=-1); /*relative reference*/ run;
Data Set Name
|
Explanation
|
---|---|
A
|
base (current) version
|
A#003
|
most recent (youngest)
historical version
|
A#002
|
second most recent historical
version
|
A#001
|
oldest historical version
|
Iteration
|
SAS Code
|
Data Set Names
|
GENNUM=Absolute Reference
|
GENNUM=Relative Reference
|
Explanation
|
---|---|---|---|---|---|
1
|
data Year
(genmax=3); |
Year
|
1
|
0
|
The data set Year is
created, and three generations are requested.
|
2
|
data Year; |
Year
Year#001
|
2
1
|
0
-1
|
Year is replaced. Year
from iteration 1 is renamed Year#001.
|
3
|
data Year; |
Year
Year#002
Year#001
|
3
2
1
|
0
-1
-2
|
Year is replaced. Year
from iteration 2 is renamed Year#002.
|
4
|
data Year; |
Year
Year#003
Year#002
|
4
3
2
|
0
-1
-2
|
Year is replaced. Year
from iteration 3 is renamed Year#003. Year#001 from iteration 1, which
is the oldest, is deleted.
|
5
|
data Year
(genmax=2); |
Year
Year#004
|
5
4
|
0
-1
|
Year is replaced, and
the number of generations is changed to 2. Year from iteration 4 is
renamed Year#004. The two oldest versions are deleted.
|
General form, PROC DATASETS
with the CHANGE and DELETE statements:
PROC DATASETS LIB=libref <NOLIST>;
CHANGE SAS-data-set<(GENNUM=n)>=new-data-set-name;
DELETE SAS-data-set<(GENNUM=n | HIST | ALL)>;
QUIT;
libref
is the library that
contains the data that you want to modify.
NOLIST
suppresses the directory
listing.
SAS-data-set
is the name of the
SAS data set you want to change or delete.
new-data-set-name
is the new name for
the SAS data set in the CHANGE statement.
n
is the absolute or
relative reference to a generation number.
HIST
refers to all generations
except the base version.
ALL
refers to the base
version and all generations.
|
proc datasets library=quarter1 nolist;
change salesData=sales;
quit;
proc datasets library=quarter1 nolist;
change sales(gennum=2)=newsales;
quit;
proc datasets library=quarter1 nolist;
delete newsales(gennum=-1);
quit;
proc datasets library=quarter1 nolist;
delete newsales(gennum=HIST);
quit;
proc datasets library=quarter1 nolist;
delete newsales(gennum=ALL);
quit;