SETVALUESET LOGIC

Discussions about tools to complement CSPro data processing
Forum rules
New release: CSPro 8.0
Post Reply
segxy4manu
Posts: 37
Joined: August 31st, 2016, 5:51 pm

SETVALUESET LOGIC

Post by segxy4manu »

Good day folks,
please i need a quick one on this on how to write a logic for a setvalueset for an item that i did not used as VS1, VS2, VS3 and so on.
example this is the way i wrote it before and it work

preproc

If(EAD_STA = 1)then
setvalueset (LGA_CODE,LGA_CODE_VS1);
elseif EAD_STA = 2 then
setvalueset (LGA_CODE,LGA_CODE_VS2);
elseif EAD_STA = 3 then
setvalueset (LGA_CODE,LGA_CODE_VS3);
elseif EAD_STA = 4 then
setvalueset (LGA_CODE,LGA_CODE_VS4);
elseif EAD_STA = 5 then
setvalueset (LGA_CODE,LGA_CODE_VS5);
elseif EAD_STA = 6 then
setvalueset (LGA_CODE,LGA_CODE_VS6);
elseif EAD_STA = 7 then
setvalueset (LGA_CODE,LGA_CODE_VS7);
Endif;

but i want a choice of selection in which the value set are not cascaded but you can just say

if A = 1 then
setvalueset (B, B_V1 to display valueset of 1:23 )
elseif A = 2 then setvalueset (B, B_VS1 to display valueset for 24:44)
Endif;

Please i need this soon

Thanks
aaronw
Posts: 561
Joined: June 9th, 2016, 9:38 am
Location: Washington, DC

Re: SETVALUESET LOGIC

Post by aaronw »

This should do the job. However, you'll need to update the loop index and condition to mark where each segment of the value set begins and ends:
PROC FIELD_1

    // FIELD_1_VS1 =
    //  1 - opt 1
    //  2 - opt 2
    //  3 - opt 3
    //  4 - opt 4

preproc

    valueset
vs;

   
if VS_ID = 1 then

        do numeric
code = 1 while code <= 2
           
vs.add(getlabel($, code), code);
       
enddo;

   
elseif VS_ID = 2 then

        do numeric
code = 3 while code <= 4
           
vs.add(getlabel($, code), code);
       
enddo;

   
endif;

   
setvalueset($, vs);
etuser
Posts: 85
Joined: September 3rd, 2019, 5:57 am

Re: SETVALUESET LOGIC

Post by etuser »

Dear Arron,

here. what is Vs_ID ?
aaronw
Posts: 561
Joined: June 9th, 2016, 9:38 am
Location: Washington, DC

Re: SETVALUESET LOGIC

Post by aaronw »

VS_ID is used to determine the range of value sets that are used. For example, if VS_ID = 1 then the value set will consist of opt 1 and opt 2, otherwise if VS_ID = 2 then the value set will consist of opt 3 and opt 4.
Post Reply