IMSTAT Procedure

Example 8: Storing Temporary Variables

Details

Many statements offer a SAVE= option that is used to save the result table of the statement for use in other IMSTAT procedure statements. You can use the STORE statement to assign a value from the saved result table to a macro variable.

Program

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

data example.prdsale(partition=(country region)); set sashelp.prdsale; run;

proc imstat data=example.prdsale immediate noprint; 1
    percentile actual / partition="U.S.A.", "EAST" save=tab1; 2
run;
    percentile actual / partition="CANADA", "EAST" save=tab2;
run;

    store tab1(3,5) = us_SeventyFivePct; 3
run;
    store tab2(3,5) = ca_SeventyFivePct;
run;
%put %sysevalf(&us_SeventyFivePct - &ca_SeventyFivePct);

    replay tab2; 4
run;

    free tab1 tab2; 5
    free macro=us_SeventyFivePct;
    free macro=ca_SeventyFivePct;
quit;

Program Description

  1. The NOPRINT option suppresses displaying the results tables.
  2. The results tables for the PERCENTILE statements are saved to temporary tables.
  3. The STORE statements access the results tables and store the value from the fifth column in the third row (the 75th percentile) to macro variables.
  4. The REPLAY statement displays the results table for the second PERCENTILE statement.
  5. The FREE statements releases the memory used by results tables and the macro variables.

Log Output

The SAS log describes how the values are stored to the macro variables.
     store tab1(3,5) = us_SeventyFivePct;
NOTE: The numeric value 746.5 from row 3, column 5 of table tab1 has been stored
      in the macro variable us_SeventyFivePct.
   run;

     store tab2(3,5) = ca_SeventyFivePct;
NOTE: The numeric value 759.5 from row 3, column 5 of table tab2 has been stored
      in the macro variable ca_SeventyFivePct.