Page 1 of 1

getlabel from dynamic value

Posted: May 1st, 2019, 4:58 am
by lusia
Dear CSPro Team,
I tried to get the value label from a dynamic value in a roster.
But either it fills in blank, it just show the value with the code 1.
Here is the logic i used:

Code: Select all

PROC B01
preproc
	// numeric indeks;
	// do indeks = 1 while indeks in loadcase(NAMA_ART_DICT)
		// if visualvalue(A5) = NORESP and visualvalue(NO_ART(indeks)) = KODEART then
			// B01(indeks) = NAMAART;
		// endif;
	// enddo;
	
	// do numeric indeks = 1 while indeks <= totocc(B_DAFTAR_ART000)
		FindRespName = loadcase(NAMA_ART_DICT);
		if visualvalue(A5) = NORESP and visualvalue(NO_ART) = KODEART then
			B01 = NAMAART;
		endif;
	// enddo;
And here is the logic I used for the dynamic value.

Code: Select all

PROC NO_ART	
onfocus
	
	numeric nextEntry = 1;
	forcase LIST_ART_DICT where NO_RESP = A5 do
		codes(nextEntry) = KODE_ART;
		labels(nextEntry) = strip(NAMA_ART);
		nextEntry = nextEntry + 1;
	enddo;
	codes(nextEntry) = notappl;
	setvalueset($, codes, labels);

    numeric vs_counter = 1;
    
    do numeric vs_value = minvalue(NO_ART) while vs_value <= maxvalue(NO_ART)

        // check if there is a label for this value, meaning that it is a valid option
        if getlabel(NO_ART, vs_value) <> "" then
			
            // make sure that this value hasn't been used
            if not (NO_ART has vs_value) then

                // add it to the value set
                vs_codes(vs_counter) = vs_value;
                vs_labels(vs_counter) = getlabel(NO_ART, vs_value);
                inc(vs_counter);

            endif;

        endif;

    enddo;

    // end and set the value set
    vs_codes(vs_counter) = notappl;

    setvalueset(NO_ART, vs_codes, vs_labels);

I do not know what is wrong with the getlabel logic. It works on a dummy project. But when I implement in this, it didn't worked. I've tried another combination but I get the ERROR: "Variable(s) length do not agree with dictionary ID length near line 10 in B01 procedure". In fact I've create a similar length with different item name in those dictionary.

Kindly please help me.

Warm Regards,
lusia

Re: getlabel from dynamic value

Posted: May 1st, 2019, 11:14 am
by Gregory Martin
It's hard to tell just from you code. You can post your application and we can look at that actual program.

However, when you're constructing the value set for NO_ART, is there a base value set that you're working off of? If so, your calls to minvalue/maxvalue/getlabel should use that value set name. If NO_ART doesn't have a value set, then getlabel will always return blank.

Re: getlabel from dynamic value

Posted: May 1st, 2019, 8:39 pm
by lusia
Yes, there is a base valueset in NO_ART. But it just a base. There are no real valueser in NO_ART.
I've sent the application to cspro@lists.gov with subject lusia's application.
Thank you in advance

Warm Regards,
Lusia

Re: getlabel from dynamic value

Posted: May 2nd, 2019, 11:14 am
by Gregory Martin
Can you send the attachment to cspro@lists.census.gov?

Re: getlabel from dynamic value

Posted: May 2nd, 2019, 11:40 am
by lusia
Yes, I mean I've attached the file to cspro@lists.census.gov. But I got a notification that the file is too big so it needs your approvement.