1
votes

I'm running a 'proc means' command to print out summary stats on two variables below: var1 and var2. I'm creating latex on-the-fly and picking the latex up in a larger document with the appropriate headers for the table and all that. It works perfectly if I have only one variable in the 'var' part of the PROC MEANS command. I can even have a number of class statements there and it works. However, if I add another variable to the 'var' statement, there is a carriage return missing from the latex output.

This is the output I'm getting:

var1    & 1.0    & 1.0    & 1.0    & 1.0    & 1.0    & 
var2 & 1.0    & 1.0    & 1.0    & -1.0.00    & 1.0   \tabularnewline

This is the output I want:

var1 & 1.0    & 1.0    & 1.0    & 1.0    & 1.0     \tabularnewline
var2 & 1.0    & 1.0    & 1.0    & 1.0    & 1.0   \tabularnewline

I'm using the following sas command to create the table (which does display perfectly in the SAS results viewer).

ods tagsets.customMinimal file="summaryPanelA_data.tex" (notop nobot) newfile=table;
proc means data=phd.formatted mean median stddev min max maxdec=2;
var stake payout;
run;
ods tagsets.customMinimal close;

I've tried using all the original tagsets for latex output i.e. Latex, SimpleLatex and TablesOnlyLatex, but it still doesn't print an end-of-line character.

This is the contents of my customer tagset:

*START REGION: Running this creates a new template;
Proc template;
define tagset Tagsets.customMinimal;
define event byline;end;
define event proc_title;end;
define event note;end;
define event Error;end;
define event Warn;end;
define event Fatal;end;
define event system_footer;end;
define event leaf;end;
define event proc_branch;end;
define event branch;end;
define event pagebreak;end;
define event system_title;end;
define event table;end;
define event table_head;end;
define event colspecs;end;
define event colspec_entry;end;
define event row;

        break /if ^contains( $HTMLCLASS, "data");
        put "                " NL "  " /if ^exists( $colspan);
    finish:     
        break /if cmp( $sascaption, "true");
        break /if contains( HTMLCLASS, "data");
        break /if ^exists($hasdata);
        put "\tabularnewline" NL /if ^exists( $colspan);
        unset $hasdata;
end;

define event data;
    start:
        put VALUE /if cmp( $sascaption, "true");

        break /if cmp( $sascaption, "true");
        break /if ^contains( HTMLCLASS, "data");
        break /if exists( $colspan) | exists ( $cell_align );

        put %nrstr(" & ") /if ^cmp( COLSTART, "1");

        unset $colspan;
        set $colspan colspan;     
        set $hasdata '1';    

        /*put tranwrd(VALUE,"-","$-$") /if contains( HTMLCLASS, "data"); */
        put tranwrd(VALUE,"-","-") /if contains( HTMLCLASS, "data");
        put VALUE /if ^contains( HTMLCLASS, "data");
        put "   ";

    finish:
        break /if ^contains( HTMLCLASS, "data");
        break /if cmp( $sascaption, "true");
        break /if exists( $colspan) | exists ( $cell_align );
end;

parent = tagsets.simplelatex;
end;

quit;

1

1 Answers

1
votes

I believe this is a problem with the PROC MEANS ODS template. If you have 9.3 you can use the STACKODSOUTPUT option (see the documentation ), but for 9.2 or earlier I don't believe there is an easy solution. Your best bet in that case would probably be to put the PROC MEANS out to a dataset, manipulate it, then PROC PRINT it to your LaTeX solution.