getlabel by position

What would you like to see in CSPro?
Post Reply
Posts: 499
Joined: July 22nd, 2016, 3:55 pm

getlabel by position

Post by AriSilva » March 6th, 2018, 6:32 am

Hi folks,
I´m using the getlabel function to retrieve the labels in the valueset of a variable.
The problem is that we have to know in advance which are the existing values in the valueset. For example, if the values are 1....9, I can execute a do loop retrieving them
do varying i = 1 until i > 9
x = getlabel(E17_MENOS_VS1,i);

But suppose that the values are not in order, like 1,4,8,9,17,99?
Then I would have to retrieve them one by one.
What I´m suggesting is that we might have something like the dynamic setvalueset, for example, getvalueset, but instead of returning a single value for the function, it would return the values and the labels in the arrays. Like

Or a function to retrieve the codes and another function to retrieve the labels for an index in the valueset. For example:
where i would be the ith entry in the valueset.

We might need also the size of the valueset, in order to execute that in a do loop, like
do varying i = 1 until i > lentgh(district_vs1)
x = getvaluesetcode(district_vs1,i);
y = getvaluesetlabel(district_vs1,i);

I know it is a little bit farfetched, but why not?

Gregory Martin
Posts: 1534
Joined: December 5th, 2011, 11:27 pm
Location: Washington, DC

Re: getlabel by position

Post by Gregory Martin » March 6th, 2018, 9:42 am

There has been discussion about adding enhanced value set operations in a future release. For now, you can skip over unused values by checking if getlabel returns blank. This code would allow you to only process the values in your value set:
do ctr = minvalue(FIELD_NAME) while ctr <= maxvalue(FIELD_NAME)

    if getlabel(FIELD_NAME,ctr) <> "" then
        // process


Post Reply