Help using Base SAS procedures

Using Proc tabulate to display statistical analysis

Reply
N/A
Posts: 0

Using Proc tabulate to display statistical analysis

Help! Does anyone know how to combine the results of a GLM analysis in a summary's table to indicate significance between the levels in a classification variable? For example, the variable Sales is analyzed in the class variable Advertising which consist of Paper, TV and Radio using Proc GLM. The significant difference in sales between the various mode of advertising will be displayed in a table generated by Proc Tabulate. To indicate significance between Paper and Radio, I would manually type in the letter A in superscript next to the sales data for Paper and Radio. Is there a way to link the results of the Proc GLM to the Proc Tabulate table so any significance between the modes of advertising would be automatically displayed one way or another?
Super Contributor
Posts: 260

Re: Using Proc tabulate to display statistical analysis

Posted in reply to deleted_user
Hi.
I think this is gonna be a lot of sweat & tears to stick to Tabulate to display your result, because if Tabulate can create crosstabs, they can only contain numeric values -- and superscripting will definitely need text. Plus it will be hard to conditonnally add the superscript in cells.
I tried to create a SAS dataset that would look like the crosstab, and then just display it with the Print procedure.
[pre]
ODS EXCLUDE ALL ; /* turns off printing */
ODS OUTPUT CLDiffs = work.differences ; /* saves results to a SAS dataset */
PROC GLM DATA = sashelp.shoes ;
CLASS region ;
MODEL sales = region ;
MEANS region / TUKEY ;
RUN ; QUIT ;
ODS SELECT ALL ; /* turns on printing */
DATA work.differences ;
SET work.differences ;
row = STRIP(SCAN(comparison, 1, "-")) ; /* will be rows for crosstab */
col = STRIP(SCAN(comparison, 2, "-")) ; /* will be columns for crosstab */
/* and now, the text in each cell for crosstab */
/* with an extra superscript A if significant */
cell = PUT(difference, 8.2) !! IFC(significance=1,"^{super a}", "") ;
RUN ;
/* sort row values */
PROC SORT DATA=work.differences ;
BY row col ;
RUN ;
/* transpose to create the crosstab */
PROC TRANSPOSE DATA=work.differences OUT=work.for_print (DROP=_name_) ;
BY row ;
ID col ;
IDLABEL col ;
VAR cell ;
RUN ;
/* most of the job is done, there is just a matter of cosmetics */
/* save column names to display them in the same order as the rows */
PROC CONTENTS DATA=work.for_print (DROP=row) NOPRINT OUT=work.varNames ;
RUN ;
PROC SQL NOPRINT ;
SELECT STRIP(name) INTO : varList SEPARATED BY " "
FROM work.varNames
ORDER BY 1
;
QUIT ;
/* now print */
OPTION ORIENTATION=LANDSCAPE NODATE NONUMBER ;
ODS PDF FILE="c:\temp\test glm.pdf" NOTOC ;
/* we need to tell SAS that in ^{super a}, ^ is an escape character */
ODS ESCAPECHAR="^" ;
TITLE ;
/* we add a little footnote for comprehension */
FOOTNOTE1 "^{super a}Significant difference" ;
PROC PRINT DATA = work.for_print LABEL NOOBS
STYLE(DATA)=[JUST=RIGHT] ; /* right-align cell contents */
ID row ;
LABEL row="Difference between means" ;
VAR &varList ; /* order columns as rows are orderred */
RUN ;
ODS PDF CLOSE ;
OPTION ORIENTATION=PORTRAIT ;
[/pre]
Does it look like what you want ?
Olivier
SAS Super FREQ
Posts: 8,868

Re: Using Proc tabulate to display statistical analysis

Hi:
A much simpler approach is to attach the superscript to the CLASSLEV value for the row where the number is of interest. If you wanted to automate the process, you'd still have to make your own custom format, but this approach will annotate the Country with a superscript 1.

cynthia
[pre]
proc format;
value $cnote 'GERMANY' = 'Germany ^{super 1}'
'CANADA' = 'Canada'
'U.S.A.' = 'United States';
run;

ods html file='c:\temp\addchar.html' style=sasweb;
ods escapechar='^';
proc tabulate data=sashelp.prdsale ;
title 'Use ODS ESCAPECHAR';
footnote '^{super 1} There is a note here about the analysis for Germany.';
class country region prodtype;
var actual;
table country*region,
prodtype*actual*mean*f=mnfmt.;
format country $cnote.;
run;
ods html close;
[/pre]
Ask a Question
Discussion stats
  • 2 replies
  • 165 views
  • 0 likes
  • 3 in conversation