Hi,
I'm struggling with what seemed like a simple task - based on the documentation:
"2001-Wife/"Wife"'s employment status ER17786, ER17787, ER17788
In order to create an equivalent employment status variable for
Heads/Wives/"Wives" using the above mentions, a user must consider the code
values of all three mentions and prioritize them in order as follows:
2,1,3,4,5,7,6,8, 9. For example, if Head had two mentions for employment
status, and the first mention was code 1 with the second mention being code 2,
then Head's overall employment status would become code 2. If Head had three
mentions for employment status with codes of 5, 6, 3, then Head's overall
employment status would become code 3."
I've tried 2 different arrays - but think I now need to order the 3 employment 'parts' by the odd numeric order before putting them through the array, maybe. I'll include my 2 attempts below. The problem is if the new variable is assigned a '2' it can later become a '7' in the code below - which I don't want.
Thank you.
Attempt 1 at creating a WIFE employment status variable:
data test2 (drop=i);
set trial1;
* rank employment vars;
head_status_01 = .;
array m{3} ER17216-ER17218;
do i=1 to 3 while (head_status_01 = .);
if m{i} = 2 then head_status_01 = 2;
else if m{i} = 1 then head_status_01=1;
else if m{i} = 3 then head_status_01=3;
else if m{i} = 4 then head_status_01=4;
else if m{i} = 5 then head_status_01=5;
else if m{i} = 7 then head_status_01=7;
else if m{i} = 6 then head_status_01=6;
else if m{i} = 8 then head_status_01=8;
else if m{i} = 9 then head_status_01=9;
end;
run;
*****************************
attempt 2
data test2 (drop=i);
set trial1 (obs=1000);
* rank employment vars;
head_status_01 = .;
array m{3} ER17216-ER17218;
array const{9} (2 1 3 4 5 7 6 8 9);
do j=1 to 9;
do i=1 to 3 while (head_status_01 ne .);
if m{i} = const{j} then head_status_01 = const{j};
end;
end;
run;