Previous Page | Next Page

TEMPLATE Procedure: Managing Template Stores

SOURCE Statement


Writes the source code for the template specified to the SAS log.
Featured in: Viewing the Source of a Template

SOURCE item-path </ option(s)>;


Required Arguments

item-path

specifies the path of the item that you want to write to the SAS log. If the same item exists in multiple template stores, PROC TEMPLATE uses the one from the first template store that you can read in the current path.

Tip: PROC TEMPLATE stores items in compiled form. The SOURCE statement actually decompiles the item. Because SAS comments are not compiled, comments that are in the source code do not appear when you decompile the item. If you want to annotate the item, use the NOTES statement inside the item or the block of editing instructions, or use the NOTES= option in the LINK statement. These notes do become part of the compiled item. (See NOTES Statement and the discussion of the NOTES= option. You can also specify notes as quoted strings in the DYNAMIC, MVAR, NMVAR, REPLACE, and STYLE statements.)

Options

FILE= 'file-specification' | fileref

specifies a file to write the item to.

'file-specification'

is the name of an external file to write to.

Requirement: The external-file that you specify must be enclosed in quotation marks.
fileref

is a file reference that has been assigned to an external file. Use the FILENAME statement to assign a fileref.

Default: If you omit a filename where you want the source code written, then the SOURCE statement writes the source code to the SAS log.
See: "Statements" in SAS Language Reference: Dictionary for information about the FILENAME statement.
NOFOLLOW

specifies that the program not resolve links in the PARENT= statement, which specifies the item that the current item inherits from. For information about the PARENT= statement, see the PARENT= statement in the styles attribute section.

STORE= libref.template-store

specifies the template store where the item is located.

Interaction: In most cases, the STORE= option is added to the definition statement when PROC TEMPLATE displays the source code. However, if the template store specified in the STORE= option is in the ODS path with only read permission, then PROC TEMPLATE does not include the STORE= option in the source code that it displays. There will be no STORE= option, which means that if you run the code, then the item that it creates will go to the first template store for which you have Update permission in the ODS path.
WHERE=(where-expression)

selects items that meet a particular condition. For example, the following statement displays the source code for items that contain the word "Default" in the path to the current template:

source / where=(path ? 'Default');

where-expression

is an arithmetic or logical expression that consists of a sequence of operators and operands.

where-expression has this form:

(subsetting-variable <comparison-operator where-expression-n>)

subsetting-variable

a special kind of WHERE expression operand used by the SOURCE statement to help you find common values in items. Subsetting variables are one or more of the following:

PATH | _PATH_

is the fully qualified path of a template.

Alias: NAME | _NAME_
Alias: TEMPLATE | _TEMPLATE_
Example: This SOURCE statement displays the code for all items that contain the word "Default" in the name of the current template:
source / where=(path ? 'Default');
run;
TYPE | _TYPE_

is the type of the item. TYPE is one of the following:

COLUMN

specifies that the template is a column in a table.

FOOTER

specifies that the template is a footer in a table.

HEADER

specifies that the template is a header in a table.

LINK

specifies that the template is a link or URL.

STYLE

specifies that the definition is a style.

TABLE

specifies that the definition is a table template .

TAGSET

specifies that the definition is a tagset.

Example: This SOURCE statement displays the source code for all tagsets that have the word "Default" in the path :
source / where=(lowcase(type) = 'tagset' && _path_ ? 'Default');
The LOWCASE function converts all letters in an argument to lowercase.
NOTES

is the content of any NOTES statement in the PROC TEMPLATE step that created the item. The contents is displayed in the LABEL field.

Alias: LABEL
Example: This SOURCE statement displays the source code for all items where the label contains the words "common matrix" and the item is a link:
source / where=(lowcase(label) ? 'common matrix' && _type_ = 'Link');
run;
The LOWCASE function converts all letters in an argument to lowercase.
SIZE

is the size of the item in bytes.

Example: This SOURCE statement displays the source code for all items that are larger than 70000 bytes:
source / where=(size > 70000);
run;
CREATED

is the date the item was created.

Example: This SOURCE statement displays the source code for all of the items that were created today in all of the template stores in the current template path :
source / where=(datepart(created) = today());
The DATEPART function extracts the date from a SAS datetime value.
CDATE | _CDATE_

is the creation date of the item.

Example: This SOURCE statement displays the source code for all of the items with a creation date of 16JUL2004:
source / where=(_cdate_ = '16JUL2004'd); 
run;
CDATETIME | _CDATETIME_

is the creation datetime of the item.

Example: This SOURCE statement displays the source code for all items with a creation SAS datetime of May 1, 2003 at 9:30:
source / where=(_cdatetime_ = '01may04:9:30:00'dt); 
run;
CTIME | _CTIME_

is the creation time of the item.

Example: This SOURCE statement displays the source code of all items with a creation time of 9:25:19 PM:
source / where=(_ctime_ = '9:25:19pm't); 
run;
MDATE | _MDATE_

is the modification date of the item.

Example: This SOURCE statement displays the source code of all items with a modification date of 16JUL2004:
source / where=(_mdate_ = '16JUL2004'd); 
run;
MDATETIME | _MDATETIME_

is the modification datetime of the item.

Example: This SOURCE statement displays the source code of all items with a modification SAS datetime of May 1, 2003 at 9:30:
source / where=(_mdatetime_ = '01may04:9:30:00'dt); 
run;
MODIFIED

is the date the item was modified.

Example: This SOURCE statement displays the source code of all items that were modified today in all of the template stores in the current template path :
source / where=(datepart(modified) = today());
The DATEPART function extracts the date from a SAS datetime value.
MTIME |_MTIME_

is the modification time of the item.

Example: This SOURCE statement displays the source code of all items with a modification time of 9:25:19 PM:
source / where=(_mtime_ = '9:25:19pm't); 
run;
comparison-operator

compares a variable with a value or with another variable. The following table lists the comparison operators:

Comparison Operators
Symbol Mnemonic Equivalent Definition
= EQ Equal to
^= or ~= or ¬= or <> NE Not equal to
> GT Greater than
< LT Less than
>= GE Greater than or equal to
<= LE Less than or equal to

IN Equal to one from a list of values

See also: For information on expressions that you can use in the WHERE data set option, see the WHERE data set option in SAS Language Reference: Dictionary and "WHERE Expression Processing" in SAS Language Reference: Concepts.

Previous Page | Next Page | Top of Page