PUT Statement, Named


Writes variable values after the variable name and an equal sign

Valid: in a DATA step

Category: File-handling

Type: Executable

Syntax

PUT < pointer-control > variable =< format. > <@ @@>;

PUT variable = start-column < ” end-column >

  • < .decimal-places > <@ @@>;

Arguments

pointer-control

  • moves the output pointer to a specified line or column in the output buffer.

  • See: Column Pointer Controls on page 1344 and Line Pointer Controls on page 1346

variable =

  • names the variable whose value is written by the PUT statement in the form

      variable  =  value  

format.

  • specifies a format to use when the variable values are written.

  • Tip: Ensure that the format width provides enough space to write the value and any commas, dollar signs, decimal points, or other special characters that the format includes.

  • Example: This PUT statement uses the format DOLLAR7.2 to write the value of X:

     put x= dollar7.2; 
  • When X=100, the formatted value uses seven columns :

     X=0.00 
  • See: Formatting Named Output on page 1370

start-column

  • specifies the first column of the field where the variable name, equal sign, and value are to be written in the output line.

” end-column

  • determines the last column of the field for the value.

  • Tip: If the variable name, equal sign, and value require more space than the columns specified, PUT will write past the end column rather than truncate the value. You must leave enough space before beginning the next value.

.decimal-places

  • specifies the number of digits to the right of the decimal point in a numeric value. If you specify 0 for d or omit d , the value is written without a decimal point.

  • Range: positive integer

@@@

  • holds an output line for the execution of the next PUT statement even across iterations of the DATA step. These line-hold specifiers are called trailing @ and double trailing @ .

  • Restriction: The trailing @ or double trailing @ must be the last item in the PUT statement.

  • See: Using Line-Hold Specifiers on page 1350

Details

Using Named Output With named output, follow the variable name with an equal sign in the PUT statement. You can use either list output, column output, or formatted output specifications to indicate how to position the variable name and values. To insert a blank space between each variable value automatically, use list output. To align the output in columns, use pointer controls or column specifications.

Formatting Named Output You can specify either a SAS format or a user -written format to control how SAS prints the variable values. The width of the format does not include the columns required by the variable name and equal sign. To align a formatted value, SAS deletes leading blanks and writes the variable value immediately after the equal sign. SAS does not align on the right side of the formatted length, as in unnamed formatted output.

For a complete description of the SAS formats, see Definition of Formats on page 71.

Examples

Use named output in the PUT statement as shown here.

  • This PUT combines named output with column pointer controls to align the output:

     data _null_;     input name $ 1-18 score1 score2 score3;     put name = @20 score1= score3= ;     datalines;  Joseph                  11   32   76  Mitchel                 13   29   82  Sue Ellen               14   27   74  ; 

    The program writes the following lines to the SAS log:

     ----+----1----+----2----+----3----+----4  NAME=Joseph        SCORE1=11 SCORE3=76  NAME=Mitchel       SCORE1=13 SCORE3=82  NAME=Sue Ellen     SCORE1=14 SCORE3=74 
  • This example specifies an output format for the variable AMOUNT:

     put item= @25 amount= dollar12.2; 

    When the value of ITEM is binders and the value of AMOUNT is 153.25, this output line is produced:

     ----+----1----+----2----+----3----+----4  ITEM=binders            AMOUNT=3.25 

See Also

Statement:

  • PUT Statement on page 1342




SAS 9.1 Language Reference Dictionary, Volumes 1, 2 and 3
SAS 9.1 Language Reference Dictionary, Volumes 1, 2 and 3
ISBN: N/A
EAN: N/A
Year: 2004
Pages: 704

flylib.com © 2008-2017.
If you may any questions please contact us: flylib@qtcs.net