setvalueSet, extracting from multiple choice question

Discussions about CSEntry
josh
Posts: 2403
Joined: May 5th, 2014, 12:49 pm
Location: Washington DC

Re: setvalueSet, extracting from multiple choice question

Post by josh »

Next time please post the app (use pack application from the tools menu to create a zip file) rather than the screen shot. That is easier to work with.

From the screenshot I'm guessing that you did not add the external dictionary (LF_DICT) to your application. That is why you are getting the message that LF_DICT, LF_DISTRICT and LF_TEHSIL are not defined.
pcpak
Posts: 19
Joined: September 8th, 2016, 3:45 am

Re: setvalueSet, extracting from multiple choice question

Post by pcpak »

Dear Josh, I am so sorry, i am new to CSPro. I do not know where to add the external dictionary like LF_DICT and LF_DISTRICT etc. Would be great if you could please list down steps and then I will follow those to accomplish it.
Many thanks indeed!
josh
Posts: 2403
Joined: May 5th, 2014, 12:49 pm
Location: Washington DC

Re: setvalueSet, extracting from multiple choice question

Post by josh »

From files menu, choose "Add Files" and then pick the dictionary file you want to add.
pcpak
Posts: 19
Joined: September 8th, 2016, 3:45 am

Re: setvalueSet, extracting from multiple choice question

Post by pcpak »

Dear Josh,

I am getting closer to the solution. Currently I am getting error message for flgFOUND variable. I am not sure where i should declare this variable.

flgFOUND = loadcase(TEHSILS_DICT, DISTRICT, TEHSIL); {loads case}

Secondly, I had made my excel file as below.

District_ID Tehsil_ID Tehsil_Name


I just have viewed my lookup.dat file and it appears that values are not getting along correctly. Could you please send me any template for Excel. I have three districts and couple of tehsils within each district which I want to validate. We are not keying district or tehsil names - only the codes. For example the code of first district is 1 and there are 4 thesils (codes: 11,12,13,14) and similarly code of second district is 2 and there are 5 tehsils (codes: 21,22,23,24,25)

many thanks!!
josh
Posts: 2403
Joined: May 5th, 2014, 12:49 pm
Location: Washington DC

Re: setvalueSet, extracting from multiple choice question

Post by josh »

You can declare the flgFOUND right where you first use it:

numeric flgFOUND = loadcase(TEHSILS_DICT, DISTRICT, TEHSIL);

From the way you have your coding it sounds like there are less than 10 districts and no more than 10 districts within each Tehsil so you can make the length of each of those variables 1 digit. If I'm wrong then you can increase the number of digits.

For the lookup file your dictionary would be as follows:

id-items:
DISTRICT_ID Len 1, Type numeric
TEHSIL_ID Len 1, Type numeric
Rec:
TEHSIL_NAME Len 50 (or however long your names are), Type alpha

For the Excel you need three columns:

Code: Select all

DISTRICT_ID	TEHSIL_ID		TEHSIL_NAME
1					1				Name of Tehsil 11
1					2				Name of Tehsil 12
1					3				Name of Tehsil 13
1					4				Name of Tehsil 14
2					1				Name of Tehsil 21
2					2				Name of Tehsil 22
etc...

Use the Excel2CSPro tool and give it your lookup dictionary and the spreadsheet and it should create the correct data file.
pcpak
Posts: 19
Joined: September 8th, 2016, 3:45 am

Re: setvalueSet, extracting from multiple choice question

Post by pcpak »

Thank you so much. Sounds like i am more closer to the solution. One thing i wanted to clarify in Excel template you sent. You recommended Tehsil_ID as 1,2,3,4 and with Tehsil name you mentioned 11,12,13 etc. In my questionnaire the IDs for tehsil are two digit and starts from 11,12,13,14 etc. Should I go as you recommended or do I have to move 11,12,13...to Tehsil_ID?

thanks a lot
josh
Posts: 2403
Joined: May 5th, 2014, 12:49 pm
Location: Washington DC

Re: setvalueSet, extracting from multiple choice question

Post by josh »

You can do it either way. It looked to me like the Tehsil code included the district code (Tehsil 12 is the second Tehsil in the district 1) in which case you can make the Tehsil code one digit since you are already capturing the district. However if you prefer you can make the Tehsil code 2 digits and repeat the district code i.e. District 1 Tehsil 12 for a combined id of 112. Either way will work as long you are consistent between the lookup file dictionary and the main data entry dictionary.
pcpak
Posts: 19
Joined: September 8th, 2016, 3:45 am

Re: setvalueSet, extracting from multiple choice question

Post by pcpak »

Thank you Josh. I would prefer to have Tehsil as 2 digit because it is mentioned on the questionnaire like that, so i do not want to create confusion for the data entry operators. Here is how I will make the excel file:

District_ID Tehsil_ID Tehsil_Name
1 11 first tehsil name in first district
1 12 second tehsil name in first district
2 21 first tehsil name in 2nd district
2 22 second tehsil name in 2nd district

and so on

many thanks!
pcpak
Posts: 19
Joined: September 8th, 2016, 3:45 am

Re: setvalueSet, extracting from multiple choice question

Post by pcpak »

Below is the code for Tehsil proc. Could you please see if this is OK. It does not give any error but when I run form and enter Tehsil code, it says that "Data file is already used by another run".

DISTRICT_ID = District;
TEHSIL_ID = Tehsil;
numeric flgFOUND = loadcase(TEHSILS_DICT, DISTRICT_ID, TEHSIL_ID);
if flgFOUND = 1 then
errmsg("E10: Match found in lookup file: District %d, Tehsil %d is %s ", District, Tehsil, TEHSIL_NAME);
else
errmsg("E20: Did not find a match in lookup file for Province %d, District %d", DISTRICT_ID, TEHSIL_ID);
reenter;
endif;
josh
Posts: 2403
Joined: May 5th, 2014, 12:49 pm
Location: Washington DC

Re: setvalueSet, extracting from multiple choice question

Post by josh »

The code looks fine. That error means that you data file is open by another program. Make sure you close other programs. Also make sure you have picked the correct data file when you ran the application. You might also try rebooting the PC in case somehow the file got locked by a program that crashed.
Post Reply