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-2024.png

Available on demand!

Missed SAS Innovate Las Vegas? Watch all the action for free! View the keynotes, general sessions and 22 breakouts on demand.

 

Register now!

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.

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
  • 312 views
  • 0 likes
  • 2 in conversation