BookmarkSubscribeRSS Feed
deleted_user
Not applicable
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?
2 REPLIES 2
Olivier
Pyrite | Level 9
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
Cynthia_sas
SAS Super FREQ
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]

sas-innovate-2024.png

Join us for SAS Innovate April 16-19 at the Aria in Las Vegas. Bring the team and save big with our group pricing for a limited time only.

Pre-conference courses and tutorials are filling up fast and are always a sellout. Register today to reserve your seat.

 

Register now!

What is Bayesian Analysis?

Learn the difference between classical and Bayesian statistical approaches and see a few PROC examples to perform Bayesian analysis in this video.

Find more tutorials on the SAS Users YouTube channel.

Click image to register for webinarClick image to register for webinar

Classroom Training Available!

Select SAS Training centers are offering in-person courses. View upcoming courses for:

View all other training opportunities.

Discussion stats
  • 2 replies
  • 643 views
  • 0 likes
  • 3 in conversation