LIBNAME Statement, SASEDOC

Uses the SASEDOC engine to associate a SAS libref (library reference) with one or more ODS output objects that are stored in an ODS document.
Valid in: Anywhere
Category: ODS: Output Control
Restriction: The LIBNAME statement that is used with the SASEDOC engine provides Read access to an output object. You cannot write an output object to a library with the SASEDOC engine, but you can delete or rename a data set.

Syntax

Required Arguments

libref
is a shortcut name or a nickname for the aggregate storage location where your SAS files are stored. It is any SAS name that you choose for assigning a new libref. When you are disassociating a libref from a SAS library, or when you are listing attributes, specify a libref that was previously assigned or else use the CLEAR argument.
Tip:The association between a libref and a SAS library lasts only for the duration of the SAS session or until you change it or discontinue it with another LIBNAME statement for the same libref.
SASEDOC
is the name of the engine that associates a SAS libref (library reference) with one or more ODS output objects that are stored in an ODS document.
path
is the fully specified location of an ODS document directory.

SASEDOC Engine Options

DOC_SEQNO=sequence-number
permits you to specify the sequence number of the output object to be accessed. This is necessary when multiple output objects that are in the same directory have the same name. By default, the SASEDOC LIBNAME engine can access only the most recently created output object, which might not be the one that you want to access. Specify DOC_SEQNO to override the default.
sequence-number
is a number which, when combined with a pathname, uniquely identifies the entry in the directory.

Additional LIBNAME Statement Arguments and Options

For additional arguments and options that are valid for the LIBNAME statement, see the LIBNAME statement in SAS Statements: Reference.

Details

The SASEDOC LIBNAME engine permits you to access output objects that are stored in an ODS document. A data set that is accessed by using the SASEDOC LIBNAME engine might differ structurally from one created by replaying the ODS document output object to the ODS OUTPUT destination. This is because the ODS OUTPUT destination recognizes the output object's template, but the SASEDOC LIBNAME engine does not.

Example: Assigning a LIBNAME to an ODS DOCUMENT

Features:

ODS DOCUMENT statement: NAME= option

Other features:

LIBNAME statement: DOC_SEQNO option

PROC DATASETS

PROC GLM

PROC PRINT

Data sets: Plants

Plant_Stat

Details

This example assigns a libref to an ODS document directory that contains four output objects created by PROC GLM. The four output objects are tables:
  • Overall ANOVA
  • Fit statistics
  • Type I model ANOVA
  • Type III model ANOVA

Program

ods document name=sasuser.odsglm(write);
proc glm  data=plant_stats;
  class month;
  model age age2 age3=month / nouni;
  manova h=month /print;
run;
proc glm  data=plants order=data;
   class type block;
   model stemleng=type block;
   means type;
   contrast 'compost vs others'  type -1 -1 -1 -1  6 -1 -1;
   contrast 'river soils vs.non' type -1 -1 -1 -1  0  5 -1,
                                 type -1  4 -1 -1  0  0 -1;
   contrast 'glacial vs drift'   type -1  0  1  1  0  0 -1;
   contrast 'clarion vs webster' type -1  0  0  0  0  0  1;
   contrast 'knox vs oneill'     type  0  0  1 -1  0  0  0;
quit;  
ods document close;
libname mylib sasedoc '\sasuser.odsglm\glm\anova#1\stemleng';
proc datasets lib=mylib;
run;
quit;
proc print data=mylib.modelanova;
run;
proc print data=mylib.modelanova(doc_seqno=1);
run;

Program Description

Create the ODS document and open the DOCUMENT destination.The ODS DOCUMENT statement opens the DOCUMENT destination. The NAME= option assigns the name sasuser.odsglm to the ODS document that will contain the output from the PROC GLM program. The access-option WRITE provides Write access to the document. Note that odsglm will be created in the Sasuser library.
ods document name=sasuser.odsglm(write);
Create the output objects.The GLM procedure creates the output objects. The Plant_Stats data set contains the statistical information that PROC GLM uses to create the output objects.
For information about viewing a record of each output object that is created, see the ODS TRACE Statement.
proc glm  data=plant_stats;
  class month;
  model age age2 age3=month / nouni;
  manova h=month /print;
run;
Create the output objects. The GLM procedure creates the output objects. The Plants data set contains the statistical information that PROC GLM uses to create the output objects.
For information about viewing a record of each output object that is created, see the ODS TRACE Statement.
proc glm  data=plants order=data;
   class type block;
   model stemleng=type block;
   means type;
   contrast 'compost vs others'  type -1 -1 -1 -1  6 -1 -1;
   contrast 'river soils vs.non' type -1 -1 -1 -1  0  5 -1,
                                 type -1  4 -1 -1  0  0 -1;
   contrast 'glacial vs drift'   type -1  0  1  1  0  0 -1;
   contrast 'clarion vs webster' type -1  0  0  0  0  0  1;
   contrast 'knox vs oneill'     type  0  0  1 -1  0  0  0;
quit;  
Close the DOCUMENT destination.If you do not close the DOCUMENT destination, you will be unable to see DOCUMENT procedure output.
ods document close;
Associate the libref mylib with the directory stemleng. The LIBNAME statement uses the SASEDOC engine to associate the SAS libref mylib with the directory stemleng that is stored in the ODS document sasuser.odsglm. Notice that the path includes anova#1 and not just anova. This is because there are two anova directories, and this code is specifying the first directory. If the sequence number was omitted, then ODS would associate the libref with the second directory.
libname mylib sasedoc '\sasuser.odsglm\glm\anova#1\stemleng';
The LIBRARY= option specifies mylib as the procedure input library. The QUIT statement stops the DATASETS procedure.
proc datasets lib=mylib;
run;
quit;
Print the data sets.Since two output objects have the same name (ModelANOVA), the SASEDOC LIBNAME engine recognizes only the second table, because it was created more recently than the first table. The DOC_SEQNO= data set option specifies a sequence number of 1 in order to access the first table.
proc print data=mylib.modelanova;
run;
proc print data=mylib.modelanova(doc_seqno=1);
run;

Output

The first display shows the Explorer window that contains the SAS library Mylib which is associated with the directory stemleng. The stemleng directory is stored in the ODS document sasuser.odsglm. The second display shows the Explorer window that contains the contents of the SAS library Mylib. The three output objects are actually stored in an ODS document.
Explorer Window
Explorer Window
The Contents Of Mylib
The Contents of Mylib