Previous Page | Next Page

The PRINTTO Procedure

Example 3: Using Procedure Output as an Input File


Procedure features:

PRINTTO statement:

Without options

Options:

LOG=

NEW

PRINT=


This example uses PROC PRINTTO to route procedure output to an external file and then uses that file as input to a DATA step.

 Note about code
   data test;
      do n=1 to 1000;
         x=int(ranuni(77777)*7);
         y=int(ranuni(77777)*5);
         output;
      end;
   run;
 Note about code
   filename routed 'output-filename';
   proc printto print=routed new;
   run;

 Note about code
   proc freq data=test;
      tables x*y / chisq;
   run;
 Note about code
   proc printto print=print;
   run;
 Note about code
   data probtest;
      infile routed;
      input word1 $ @;
      if word1='Chi-Squa' then
         do;
            input df chisq prob;
            keep chisq prob;
            output;
         end;
   run;
 Note about code
   proc print data=probtest;
      title 'Chi-Square Analysis for Table of X by Y';
   run;

PROC FREQ Output Routed to the External File Referenced as ROUTED

                               The FREQ Procedure

                                Table of x by y

         x         y

         Frequency|
         Percent  |
         Row Pct  |
         Col Pct  |       0|       1|       2|       3|       4|  Total
         ---------+--------+--------+--------+--------+--------+
                0 |     29 |     33 |     12 |     25 |     27 |    126
                  |   2.90 |   3.30 |   1.20 |   2.50 |   2.70 |  12.60
                  |  23.02 |  26.19 |   9.52 |  19.84 |  21.43 |
                  |  15.18 |  16.18 |   6.25 |  11.74 |  13.50 |
         ---------+--------+--------+--------+--------+--------+
                1 |     23 |     26 |     29 |     20 |     19 |    117
                  |   2.30 |   2.60 |   2.90 |   2.00 |   1.90 |  11.70
                  |  19.66 |  22.22 |  24.79 |  17.09 |  16.24 |
                  |  12.04 |  12.75 |  15.10 |   9.39 |   9.50 |
         ---------+--------+--------+--------+--------+--------+
                2 |     28 |     26 |     32 |     30 |     25 |    141
                  |   2.80 |   2.60 |   3.20 |   3.00 |   2.50 |  14.10
                  |  19.86 |  18.44 |  22.70 |  21.28 |  17.73 |
                  |  14.66 |  12.75 |  16.67 |  14.08 |  12.50 |
         ---------+--------+--------+--------+--------+--------+
                3 |     26 |     24 |     36 |     32 |     45 |    163
                  |   2.60 |   2.40 |   3.60 |   3.20 |   4.50 |  16.30
                  |  15.95 |  14.72 |  22.09 |  19.63 |  27.61 |
                  |  13.61 |  11.76 |  18.75 |  15.02 |  22.50 |
         ---------+--------+--------+--------+--------+--------+
                4 |     25 |     31 |     28 |     36 |     29 |    149
                  |   2.50 |   3.10 |   2.80 |   3.60 |   2.90 |  14.90
                  |  16.78 |  20.81 |  18.79 |  24.16 |  19.46 |
                  |  13.09 |  15.20 |  14.58 |  16.90 |  14.50 |
         ---------+--------+--------+--------+--------+--------+
                5 |     32 |     29 |     26 |     33 |     27 |    147
                  |   3.20 |   2.90 |   2.60 |   3.30 |   2.70 |  14.70
                  |  21.77 |  19.73 |  17.69 |  22.45 |  18.37 |
                  |  16.75 |  14.22 |  13.54 |  15.49 |  13.50 |
         ---------+--------+--------+--------+--------+--------+
                6 |     28 |     35 |     29 |     37 |     28 |    157
                  |   2.80 |   3.50 |   2.90 |   3.70 |   2.80 |  15.70
                  |  17.83 |  22.29 |  18.47 |  23.57 |  17.83 |
                  |  14.66 |  17.16 |  15.10 |  17.37 |  14.00 |
         ---------+--------+--------+--------+--------+--------+
         Total         191      204      192      213      200     1000
                     19.10    20.40    19.20    21.30    20.00   100.00

                                                                               2

                               The FREQ Procedure

                         Statistics for Table of x by y

             Statistic                     DF       Value      Prob
             ------------------------------------------------------
             Chi-Square                    24     27.2971    0.2908
             Likelihood Ratio Chi-Square   24     28.1830    0.2524
             Mantel-Haenszel Chi-Square     1      0.6149    0.4330
             Phi Coefficient                       0.1652          
             Contingency Coefficient               0.1630          
             Cramer's V                            0.0826          

                               Sample Size = 1000

PROC PRINT Output of Data Set PROBTEST, Routed to Default Destination

                    Chi-Square Analysis for Table of X by Y                    3

                             Obs     chisq     prob

                              1     27.297    0.291

Previous Page | Next Page | Top of Page