IMSTAT Procedure

Example 2: Promoting Temporary Tables to Regular Tables

Details

The SUMMARY, SCORE, CROSSTAB, PERCENTILE, and DISTINCT statements offer a TEMPTABLE option. When you specify the TEMPTABLE option, the results of the statement are written to a temporary table. The PARTITION statement also results in a temporary table. If you want to keep the table, you can use the PROMOTE statement to convert the table from being a temporary table to a regular table. Once you do this, other users can access the data.

Program

libname example sasiola host="grid001.unx.sas.com" port=10010 tag='hps';

data example.prdsale; set sashelp.prdsale; run;

proc imstat data=example.prdsale;
    summary / groupby=(country) temptable; 1
run;
    table example.&_templast_; 2  
run;    
    promote sum_by_country; 3
run;
    table example.sum_by_country; 4
run;
    fetch / format to=10; 5
quit;

Program Description

  1. The TEMPTABLE option stores the results of the SUMMARY statement to a temporary table. If this table is not promoted before the QUIT statement, it is removed from memory.
  2. The TABLE statement references the _TEMPLAST_ macro variable and sets the temporary table as the active table. All statements that follow use the temporary table.
  3. The PROMOTE statement converts the temporary table to a regular table with the name Sum_By_Country. The table is associated with the current library through the libref, example. The SAS log also includes a note that indicates how to specify the libref and table name.
  4. The TABLE statement makes the table the active table explicitly by specifying the libref and table name. The Sum_By_Country table is not removed from memory when the IMSTAT procedure terminates.
  5. All the subsequent statements that follow the TABLE statement use the newly promoted table.
The example does not show the use of SAS LASR Analytic Server engine server tags. You can use server tags with the PROMOTE statement as show in the following code sample.
proc imstat data=example.prdsale;
    summary / groupby=(region) temptable; 
run;

    table example.&_templast_;   
run;    
    promote sum_by_region / tag="sales"; 
run;
    table example.sum_by_country(tag="sales"); 4
run;
quit;
As shown in the previous example, the TAG= option is used in the PROMOTE statement. To access the table, the TABLE statement uses the TAG= data set option.
As shown in the following sample, the SAS log indicates the libref, table name, and server tag to use for accessing the table.
SAS Log for the PROMOTE Statement with the TAG= Option
NOTE: The temporary table _T_BE5C2602_45A0DCB8 was successfully promoted to the 
      LASR Analytic Server table WORK.SUM_BY_COUNTRY. You can access this table with 
      the TABLE statement as table EXAMPLE.sum_by_country(tag='sales').