BookmarkSubscribeRSS Feed
☑ This topic is solved. Need further help from the community? Please sign in and ask a new question.
Mruizv
Obsidian | Level 7

Hello I am running a Gamma Test but I want to see the effects over the value when the score values are changed.

My understanding is that the default scores makes the ordinal variables as they appear with 1/2/3.... f I want something different what should be my option?

data status;
input socioecon $ mentalhealth $ count;
datalines;
low well 10
low mild 35
low moderate 26
med well 25
med mild 50
med moderate 32
high well 30
high mild 46
high moderate 26
;
run;
proc freq order=data;
weight count;
tables socioecon*mentalhealth/ scores= measures chisq relrisk riskdiff expected;
exact or;
run;
1 ACCEPTED SOLUTION

Accepted Solutions
FreelanceReinh
Jade | Level 19

Hello @Mruizv,

 

So you want to assign individual scores to the ordinal values of socioecon and mentalhealth, e.g., low=1, med=3, high=7 and well=4, mild=11, moderate=38? Then you need to create numeric variables containing these numbers, say socioecon_num and mentalhealth_num, from the existing character variables. You can use a user-defined format so that the values are still displayed as "low", "med", etc. Note, however, that the gamma statistic (unlike the Mantel-Haenszel chi-square and the Pearson correlation) will not be affected by this change.

 

Example:

data want;
set status;
socioecon_num=choosen(whichc(socioecon, 'low','med','high'),1,3,7);
mentalhealth_num=choosen(whichc(mentalhealth, 'well','mild','moderate'),4,11,38);
run;

proc format;
value socifmt
1='low'
3='med'
7='high'
;
value mentfmt
4='well'
11='mild'
38='moderate'
;
run;

proc freq data=want order=data;
weight count;
format socioecon_num socifmt. mentalhealth_num mentfmt.;
tables socioecon_num*mentalhealth_num / scorout measures chisq expected;
run;

I have added the SCOROUT option to the TABLES statement to include tables with the row and column scores in the output (and removed redundant and inapplicable options).

View solution in original post

2 REPLIES 2
FreelanceReinh
Jade | Level 19

Hello @Mruizv,

 

So you want to assign individual scores to the ordinal values of socioecon and mentalhealth, e.g., low=1, med=3, high=7 and well=4, mild=11, moderate=38? Then you need to create numeric variables containing these numbers, say socioecon_num and mentalhealth_num, from the existing character variables. You can use a user-defined format so that the values are still displayed as "low", "med", etc. Note, however, that the gamma statistic (unlike the Mantel-Haenszel chi-square and the Pearson correlation) will not be affected by this change.

 

Example:

data want;
set status;
socioecon_num=choosen(whichc(socioecon, 'low','med','high'),1,3,7);
mentalhealth_num=choosen(whichc(mentalhealth, 'well','mild','moderate'),4,11,38);
run;

proc format;
value socifmt
1='low'
3='med'
7='high'
;
value mentfmt
4='well'
11='mild'
38='moderate'
;
run;

proc freq data=want order=data;
weight count;
format socioecon_num socifmt. mentalhealth_num mentfmt.;
tables socioecon_num*mentalhealth_num / scorout measures chisq expected;
run;

I have added the SCOROUT option to the TABLES statement to include tables with the row and column scores in the output (and removed redundant and inapplicable options).

Mruizv
Obsidian | Level 7

Thank you so much, the exercise indeed is to prove that gamma doesn't change. I had done it by hand but wanted to learn how to program it.

SAS Innovate 2025: Save the Date

 SAS Innovate 2025 is scheduled for May 6-9 in Orlando, FL. Sign up to be first to learn about the agenda and registration!

Save the date!

How to Concatenate Values

Learn how use the CAT functions in SAS to join values from multiple variables into a single value.

Find more tutorials on the SAS Users YouTube channel.

SAS Training: Just a Click Away

 Ready to level-up your skills? Choose your own adventure.

Browse our catalog!

Discussion stats
  • 2 replies
  • 522 views
  • 0 likes
  • 2 in conversation