Cascade with ext. dictionary look up

Discussions about CSEntry
Post Reply
lls
Posts: 109
Joined: December 6th, 2011, 3:11 pm
Location: Geneva, Switzerland

Cascade with ext. dictionary look up

Post by lls »

Dear CSPro users,

I try to have a cascade using lookup with several external dictionaries from region>country>objective>etc…down to indicators.

1. I have been able to create a cascade from operation (country) to indicators and it worked well.
2. Then, I added one dictionary with Region as I would like to have a region filter as well but now there is a problem in the lookup function

I don’t understand what’s missing and I’m calling for your kind advice.
Please see attached the 2 versions, the one that works fine (Annex A v 1.109) and the one broken (Annex A v 1.201). I’m sure there is not much to change but I can’t figure out. Any help would be highly appreciated.

Thanks a lot in advance.

lls
Attachments
Annex A v 1.201 PROBLEM.zip
(22.14 KiB) Downloaded 358 times
Annex A v 1.109 GOOD.zip
(20.53 KiB) Downloaded 340 times
josh
Posts: 2399
Joined: May 5th, 2014, 12:49 pm
Location: Washington DC

Re: Cascade with ext. dictionary look up

Post by josh »

Maybe I'm missing something obvious but the only problem I see with region to operation cascade is that the data file only contains countries in Africa. If choose Africa (1) as the region it seems to work fine. If you add the countries for Europe, Americas... to the data file it should work for those as well.
lls
Posts: 109
Joined: December 6th, 2011, 3:11 pm
Location: Geneva, Switzerland

Re: Cascade with ext. dictionary look up

Post by lls »

Hi Josh,

Thank you for taking the time to look into it.
You are right, at the moment, I am just testing with Africa countries only. Some combination will then not work but it works (or should work) with Angola for example.

In the first version (1.109) if I select 01>101>1001>10001>100001>1000001 I will get the 2 indicators within the output and this is correct. In the other version (1.201) where I have added the region, I would like to have the same result with 1>01>101>1001>10001>100001>1000001 but I get an error message instead which is generated by the code below.

I thought the problem came from the .dat file where the indicators are looked up (List of performance indicators.dat) but I have added the number corresponding to the region (1011011001100011000011000001 0 0 Capacity support provided to government status determination staff (yes/no)).

I have added several dictionaries without problem. Only when I added the region at the beginning I had this issue. Would you have an idea?



POSTPROC

REGION_LU44 = REGION;
OPERATION_LU44 = OPERATION;
PPG_LU44 = PPG;
GOAL_LU44 = GOAL;
RG_LU44 = RIGHTS_GROUP;
OBJECTIVES_LU44 = OBJECTIVE;
OUTPUTS_LU44 = OUTPUT;

if not loadcase (LIST_OF_PERF_INDICATORS_DICT,REGION_LU44,OPERATION_LU44,PPG_LU44,GOAL_LU44,RG_LU44,OBJECTIVES_LU44,OUTPUTS_LU44) then

errmsg("aaa # %d does not exist", OUTPUTS_LU44);
reenter OUTPUT;
else
totHhd=count(LIST_OF_PERFINDIC_REC.HHD_SRNO_LU44);
errmsg("%d Indicators in Output # %d", totHhd, OUTPUT);
endif;
lls
Posts: 109
Joined: December 6th, 2011, 3:11 pm
Location: Geneva, Switzerland

Re: Cascade with ext. dictionary look up

Post by lls »

Now I have something that works but I'm strugling with loadcase to get the label in an alpha field.

Is it possible to use the lookup function with more then one field? I would like to do a lookup with field1 (length = 1) and field2 (length = 2) in external dictionalry to find a match with a field of length 3.

That is if Field1 = [1] and field2 = [01], I would like to find the match with [101]

This is because in my .dat file I have 3 digit plus text (e.g. 101Angola) 1 being the region (Africa) and 01 being the country (Angola). I use this to generate automatic value sets. I have a 3 digit field with an auto generated value set for all african countries where I can chose 101 for Angola but I dont know how to get the label (Angola) in a separate alpha field.

Thanks!
josh
Posts: 2399
Joined: May 5th, 2014, 12:49 pm
Location: Washington DC

Re: Cascade with ext. dictionary look up

Post by josh »

The way loadcase works is to concatenate all the arguments you pass it into a single string and then it matches that string with the case id's in the data file. That means that if you have REGION (1 digit) and country (2 digit) then:

loadcase(MYDICT, REGION, COUNTRY)

is exactly the same thing as:

loadcase(MYDICT, maketext("%d%02d", REGION, COUNTRY))

What usually messes people up with loadcase is that because the ids are concatenated together into a single string it is important that the variable lengths and zero fill settings of the variables in the lookup dictionary match exactly with the variables that are passed to loadcase. For example if in your lookup file COUNTRY was a 3 digit variable but the variable you passed to loadcase for country was a 2 digit variable, loadcase would never find a match.
Post Reply