New Contributor
Posts: 4

# How to do exact analysis of s by r table with nominal covariate and ordinal response?

I use SAS9.4.

I would like to do a exact analysis of s by r table where

the covariate is nominal and the response is ordinal.

Also this is an analysis of categorical data, so we observe the frequency of each covariate*response level.

So the data should look something like

data example;

input covariate \$ response \$ count @@;

datalines;

cov1 bad 3 cov1 moderate 4 cov1 good 0

cov2 bad 4 cov2 moderate 1 cov2 good 2

cov3 bad 5 cov3 moderate 2 cov3 good 1

;

The sample size is quite small, so I would like to use exact analysis.

I suppose I can do something like

froc freq order=data;

weight count;

tables covariatename*outcomename / exact

run;

But, this should give just a general association, not a "mean score differ" type of result.

What kind of option can I use to do this exact analysis?

Super User
Posts: 11,767

## Re: How to do exact analysis of s by r table with nominal covariate and ordinal response?

To do anything with "difference" I think you need your responses to be numeric. I think you might investigate Proc Npar1way.

``````proc format library=work;
invalue response
'moderate'=2
'good' =3;
run;
data example;
informat response response.;
input covariate \$ response  count @@;
datalines;
cov1 bad 3 cov1 moderate 4 cov1 good 0
cov2 bad 4 cov2 moderate 1 cov2 good 2
cov3 bad 5 cov3 moderate 2 cov3 good 1
;
run;

proc npar1Way data=example;
class covariate;
freq count;
var response;
exact Wilcoxon;

run;``````
New Contributor
Posts: 4

## Re: How to do exact analysis of s by r table with nominal covariate and ordinal response?

Thank you! I will try.
Super User
Posts: 10,198

## Re: How to do exact analysis of s by r table with nominal covariate and ordinal response?

Friedman’s Chi-Square Test can get "mean score differ" , Check example in Documentation.

proc freq data=Hypnosis;
tables Emotion * SkinResponse /cmh2 scores=rank noprint;

exact ..... ;
run;

OR You could try PROC CATMOD ,which is the best tool to build a Log-Linear Model for Contingency Table.

New Contributor
Posts: 4

## Re: How to do exact analysis of s by r table with nominal covariate and ordinal response?

Thank you. I will try!
SAS Super FREQ
Posts: 3,832

## Re: How to do exact analysis of s by r table with nominal covariate and ordinal response?

For an overview of the various exact tests in PROC FREQ, see "Exact tests in PROC FREQ: What, when, and how."

The PROC FREQ doc says "The Jonckheere-Terpstra test is appropriate for a two-way table in which an ordinal column variable represents the response."

New Contributor
Posts: 4

## Re: How to do exact analysis of s by r table with nominal covariate and ordinal response?

Thank you! I will try.
Discussion stats
• 6 replies
• 403 views
• 3 likes
• 4 in conversation