SAS: separate table names for PROC FREQ or PROC REPORT?

Instead of performing several separate procedures PROC FREQin a very large dataset, I would like to increase efficiency by doing one PROC FREQwith several statements TABLE. Our QA process requires table headers that are simple with a single statement TABLEusing a single statement TITLE, but is this possible with multiple statements TABLE?

Take the following data and code:

DATA TEST;
    INPUT TEMPERATURE HUMIDITY PLATE FORM $12.;
    DATALINES;
    25  75  1   HOT
    30  75  2   COLD
    25  45  3   HOT
    30  45  4   COLD
    25  55  5   HOT
    30  55  6   COLD
    25  15  7   HOT
    30  15  8   COLD
    ;
RUN;

** SINGLE PASS ON PROC FREQ **;
PROC FREQ DATA = TEST;
    TITLE1 "TEMPERATURE FREQS";
      TABLE TEMPERATURE / LIST OUT=FREQS_TEMP;
    TITLE2 "HUMIDITY FREQS";
      TABLE HUMIDITY / LIST OUT=FREQS_HUM;
    TITLE3 "PLATE FREQS";
      TABLE PLATE / LIST OUT=FREQS_PLATE;
    TITLE4 "FORM FREQS";
      TABLE FORM / LIST OUT=FREQS_FORM;
RUN;TITLE1;TITLE2;TITLE3;TITLE4;

The stack headers on top of each other at the very top of the output, not in each table, so is this possible at the data stage or should a custom template be created? Could there PROC REPORTbe a more viable option for user frequencies?

+4
2

, , , , proc document. , , , .

proc document , . , freq, - SAS title , . , PROC FREQ run, ( , titel1/2/3/4 - title , ).

, ( , , PROC FREQ, ). :

*ODS DOCUMENT creates the DOCUMENT object you will later modify;
ods document name=freqs(write);
** SINGLE PASS ON PROC FREQ **;
PROC FREQ DATA = TEST;
    TITLE "TEMPERATURE FREQS";
      TABLE TEMPERATURE / LIST OUT=FREQS_TEMP;
    TITLE "HUMIDITY FREQS";
      TABLE HUMIDITY / LIST OUT=FREQS_HUM;
    TITLE "PLATE FREQS";
      TABLE PLATE / LIST OUT=FREQS_PLATE;
    TITLE "FORM FREQS";
      TABLE FORM / LIST OUT=FREQS_FORM;
RUN;
title;
ods document close;


*PROC DOCUMENT is an interactive proc, so it stays active until QUIT;
proc document name=freqs;
  *Just a look at what it looks like under the hood - can be removed in production;
  list/levels=all;
run;

  *Here we create page breaks (OBPAGE command) after each table.;
  obpage \Freq#1\Table1#1\OneWayFreqs#1 /after;
  obpage \Freq#1\Table2#1\OneWayFreqs#1 /after;
  obpage \Freq#1\Table3#1\OneWayFreqs#1 /after;


  *Here we add the titles.;
  obtitle \Freq#1\Table1#1\OneWayFreqs#1 "TEMPERATURE FREQS";
  obtitle \Freq#1\Table2#1\OneWayFreqs#1 "HUMIDITY FREQS";
  obtitle \Freq#1\Table3#1\OneWayFreqs#1 "PLATE FREQS";
  obtitle \Freq#1\Table4#1\OneWayFreqs#1 "FORM FREQS";

  *And here we replay the document with the changes;
  replay ^;
run;

quit;
+3

. , . PROC FREQ .

%macro freq_out(VName, VSub);

proc freq data=test;
title "&VName Freqs";
table &vname/list out=freqs_&vsub;
run;

%mend;

%freq_out(Temperature, Temp);
%freq_out(Humidity, Hum);
-1

Source: https://habr.com/ru/post/1628141/


All Articles