I am trying to create an array which is based on answers given in 6 questions. The question is basically the same but repeated 6 times in a roster. Also, the question has 2 different value_sets
based on answer given in previous question.
if OLD_CASE then
if COMPANY = 1 then
setvalueset(Q206_A,Q206_A_VS1);
elseif COMPANY = 2 then
setvalueset(Q206_A,Q206_A_VS1);
endif;
endif;
I tried to something like the following where aFacilty and aFacilityCodes are programmed manually before in something like the following:
if COMPANY = 1 then
setvalueset(Q206_A,Q206_A_VS1);
elseif COMPANY = 2 then
setvalueset(Q206_A,Q206_A_VS1);
endif;
endif;
if COMPANY = 1 then
aFacilityCode(0)=30;
aFacility(0) ="Moi Teaching and Referral Hospital";
aFacilityCode(1) = 31;
aFacility(1) = "Kenyatta National Hospital";
aFacilityCode(2) = 32;
{I am not going to write the whole code here because it is too long, but just to give you an idea}
h=30; // h=length of array to use (the largest index for aFacility)
elseif COMPANY = 2 then
aFacilityCode(0) = 30;
aFacility(0) = "SACO clinic";
h=31;
//
//
//
endif;
aFacilityCode(0)=30;
aFacility(0) ="Moi Teaching and Referral Hospital";
aFacilityCode(1) = 31;
aFacility(1) = "Kenyatta National Hospital";
aFacilityCode(2) = 32;
{I am not going to write the whole code here because it is too long, but just to give you an idea}
h=30; // h=length of array to use (the largest index for aFacility)
elseif COMPANY = 2 then
aFacilityCode(0) = 30;
aFacility(0) = "SACO clinic";
h=31;
//
//
//
endif;
and then I tried this code and it didn't work
postproc
if Q246 = 0 and curocc()<hhsize then
skip to next;
elseif Q246 = 0 and curocc()=hhsize then
l=0;
do j=0 while j<=h
do i=1 while i<=hhsize
if (Q206_A(i)=aFacilityCode(j) or Q206_B(i)=aFacilityCode(j) or Q218_A(i)=aFacilityCode(j) or Q218_B(i)=aFacilityCode(j) or Q230(i)=aFacilityCode(j) or Q239(i)=aFacilityCode(j)) then
aTempNum(l)=aFacilityCode(j);
i=hhsize+1; // breaks loop for i;
inc(l); // increase l by 1
endif;
enddo;
enddo;
endgroup;
endif;
aTempNum(l) = notappl;
Any help would be much appreciatedif Q246 = 0 and curocc()<hhsize then
skip to next;
elseif Q246 = 0 and curocc()=hhsize then
l=0;
do j=0 while j<=h
do i=1 while i<=hhsize
if (Q206_A(i)=aFacilityCode(j) or Q206_B(i)=aFacilityCode(j) or Q218_A(i)=aFacilityCode(j) or Q218_B(i)=aFacilityCode(j) or Q230(i)=aFacilityCode(j) or Q239(i)=aFacilityCode(j)) then
aTempNum(l)=aFacilityCode(j);
i=hhsize+1; // breaks loop for i;
inc(l); // increase l by 1
endif;
enddo;
enddo;
endgroup;
endif;
aTempNum(l) = notappl;
Best,
Stavros