BookmarkSubscribeRSS Feed
N8
Obsidian | Level 7 N8
Obsidian | Level 7

Hello all, I am asking for help writing the procedure code for McGuire's (2006) 'rank and replace' method for transforming health values for minority populations to be the health values of non-minority populations. The gist of the need is this: (1) rank the health status of the minority group, (2) rank the health status of the white group, (3) switch the health status of the minority group to equal the health status of the white group according to matches on their rank position (red: if a minority person is in rank 3 and the white person is in rank 3, then the minority would receive the health status value from the white person). I've been able to array and flag all instances where minority status and rank status are the same, but i'm getting stuck on how to assign the health status values to the minority group - this should be a new column. Any suggestions? 

 

Here's sample data and where i've gotten to with it. Thanks so much if anyone can help. I'm sure this is a do until loop, but could be wrong. best, Nate

 


data sample;
input ID $ Calories $ Minority $ Rank $;
datalines;
1 1792 0 3
6 1425 0 1
9 1782 0 2
10 2019 0 3
18 2294 0 3
20 1616 0 2
21 1551 0 1
24 1791 0 2
25 1828 0 3
26 1602 0 1
34 1611 0 2
35 1424 0 1
2 2498 1 3
3 2318 1 2
4 1848 1 1
5 1698 1 1
7 1964 1 1
8 2066 1 1
11 2348 1 3
12 2127 1 2
13 2340 1 3
14 2423 1 3
15 2184 1 2
16 2337 1 3
17 2233 1 2
19 1817 1 1
22 2196 1 2
23 2697 1 3
27 2156 1 2
28 2488 1 3
29 1977 1 1
30 2074 1 2
31 2084 1 2
32 2112 1 2
33 2251 1 2
36 1509 1 1
37 2357 1 3
38 2501 1 3
39 1309 1 1

;
run;

data Sample2;
set Sample;
array MinArray {1} $ Minority;
array RnkArray {1} $ Rank;
do i=1 to 1;
if not Rank1 then Rank1=MinArray[i] in ("0","1") and RnkArray[i] in ("1") ;
if not Rank2 then Rank2=MinArray[i] in ("0","1") and RnkArray[i] in ("2") ;
if not Rank3 then Rank3=MinArray[i] in ("0","1") and RnkArray[i] in ("3") ;
end;
drop i;
run;

2 REPLIES 2
mkeintz
PROC Star

If you have, say, 5 non-minority people with RANK=3,  what function of those corresponding 5 health status values do you want to use when you encounter a minority with RANK=3?

 

Thank you for the DATA SAMPLE step, ready for use.  How about a similar step showing us the corresponding output with a new variable showing values of the adjusted health status for minorities?

 

 

--------------------------
The hash OUTPUT method will overwrite a SAS data set, but not append. That can be costly. Consider voting for Add a HASH object method which would append a hash object to an existing SAS data set

Would enabling PROC SORT to simultaneously output multiple datasets be useful? Then vote for
Allow PROC SORT to output multiple datasets

--------------------------
N8
Obsidian | Level 7 N8
Obsidian | Level 7

Thanks mkeintz, 

 

good question. After posting I thought about going about this problem another way and think it would also work using data steps and will try this weekend and post back:

 

1. For each minority group, rank their health status score from largest to smallest. This will ensure that there is an order associated with their continuous data point value ;

2. Sort the data file by minority status, rank, and the rank order of the persons health score ;

3. Create a new dataset that only has values for the white patients;

4. Join back to the original dataset based on rank + rank order of the health status score (e.g., minoity in rank 1 with highest health status score would then join to the white in rank 1 with the highest health status score, and so on)

 

It's a bit lengthy, but conceptually I think this would work. It just involves a few steps and I'd prob have to repeat some of the values in the 'white' dataset if there are more minorities than whites. But to answer your question more specifically - yes, I would want to make sure that the highest value for the white person in rank 1 would be assigned to the minority person in rank 1, the next highest value for the white person in rank 1 assigned to the second highest value for the minority person in rank 1 and so on through the quartiles.

 

Anyhow, let me try this and see how it goes. Appreciate your reply - nate

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
  • 584 views
  • 1 like
  • 2 in conversation