LookUp File

Discussions about CSEntry
Stavros
Posts: 33
Joined: February 17th, 2014, 9:12 am

LookUp File

Post by Stavros »

Hi all,

I need to create a CAPI application for a follow up household survey. In my application a have to check whether the household has all the old members plus if there are new. In order to do that I will use the household ID from the previous application and for that I will use and external look up file. I have never used a look up file is my question is how can I create an external dictionary in which only the household ID and the names if the household roster will be stored. In the baseline survey the interviews were conducted using PAPI and CSPro was used later for data entry.

Best,
Stavros
shafique arif
Posts: 68
Joined: August 25th, 2013, 1:21 am

Re: LookUp File

Post by shafique arif »

Hi Stavros

http://www.csprousers.org/downloads/wor ... Roster.zip

This is what was suggested by (our Guru) Gregory. I can even share simple example if you like via email and then happy to discuss this on Skype

Apologies if Skype chat is against forum ethics but I want to share whatever little I know about CSPro.
Stavros
Posts: 33
Joined: February 17th, 2014, 9:12 am

Re: LookUp File

Post by Stavros »

Hi Shafique

Thanks a lot for the reply, I have already looked into the example and indeed is very useful but still I do not get some parts. Let me rephrase my question using the example; from the Survey Menu System application a new pff file is created using as an external file airports.dat which is located in the Lookup Files folder, my question is how the data are already stored in this file. I guess it has something to do with the excel file inside, so in terms of order of steps for my lookup file I need first to create an excel spreadsheet with all the information I want and then save it as .dat file right?

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

Re: LookUp File

Post by Gregory Martin »

If you already have the data entered from the previous round of the survey, you could:

1) Modify the dictionary from the previous round, removing everything that you don't want. In order words, keep only the household ID and the names on the household roster.

2) Reformat the data from the previous round, using the Reformat Data tool, to match this new dictionary.

3) Attach that dictionary to your new data entry program.

You will use that dictionary as your lookup dictionary and the reformatted data file as your lookup data file. Then you'll write code in your new program, something like this:
if loadcase(PREVIOUS_ROUND_DICT,HOUSEHOLD_ID) then // the case was in the last round

    
numeric ctr;

    
do ctr = 1 while ctr <= count(THIS_ROUND_NAMES)

        
if seek(PREVIOUS_ROUND_NAMES = THIS_ROUND_NAMES(ctr)) then
            
// this is an old member

        
else
            
// this is a new member

        
endif;

    
enddo;

endif;
Stavros
Posts: 33
Joined: February 17th, 2014, 9:12 am

Re: LookUp File

Post by Stavros »

Hi Gregory,

Thanks very much for the reply, I managed to do it and indeed the example is very useful.
Stavros
Posts: 33
Joined: February 17th, 2014, 9:12 am

Re: LookUp File

Post by Stavros »

Hi Gregory,

I still face some issues so I would like to ask for your help again.

Since I have the data from the previous survey I exported them using CSPro format. I exported only the Household ID and the Household Names. In that way I have my LookUp Dictionary plus my LookUp data file. The issue I face is that in the LookUp data file the Household ID and the Household names are attached with each other. In other words they are not separated by different columns as in the airports data file in the example. To get a better picture of what I mean have a look at the screenshot below

My LookUp data file:
https://www.dropbox.com/s/sr2z7h6rjzawd ... .26.58.png
Airports LookUp data file:
https://www.dropbox.com/s/phsp1hkkzf0se ... .27.40.png

Can that be the reason my code does not work? I am trying to replicate the example and enter in the userbar the Household ID so to get a text box with the Household Names

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

Re: LookUp File

Post by Gregory Martin »

It doesn't matter if the names are separated in different columns by spaces, or by no spaces. All that matters is that your dictionary matches your data file. You might consider running the Tabulate Frequencies tool and retrieving frequencies of each of the variables in your external file just to make sure that the dictionary is correct.

If that doesn't work, perhaps you can send me your application and I can take a look at how you're using the lookup file: csprousers@gmail.com
vanndy
Posts: 30
Joined: May 10th, 2012, 10:45 pm

Re: LookUp File

Post by vanndy »

Dear Gregory,

I just review about look up file. I have a similar problem to this. I want to load the look up which has only HH_ID and HH_name, It shows the error like the attached file.

Thanks,
Attachments
loading_file.png
loading_file.png (189.26 KiB) Viewed 10751 times
Gregory Martin
Posts: 1796
Joined: December 5th, 2011, 11:27 pm
Location: Washington, DC

Re: LookUp File

Post by Gregory Martin »

Vanndy,

In your case you need to specify two files:

1) The Input Data File, which is your main data file to which you want to write out data that is entered in CSEntry.

2) HOUSEHOLD_SURVEY__2014_DICT, which should point to your lookup file, which will contain the HH_ID and HH_NAME variables.
Stavros
Posts: 33
Joined: February 17th, 2014, 9:12 am

Re: LookUp File

Post by Stavros »

Hi Gregory,

I managed fine with the Lookup File thanks a lot for your comments. As I am now working with the CAPI program I have some questions regarding some of the things that I would like to have in my program.

First of all I am using the LookUp file to check hhid,names,age etc from a household roster as I am currently working on a follow-up survey.What I would like to know is if it is possible to use the names of the look up with an array as a valueset for my current roster. To be a bit more specific there is the Household ID(HHID), Names (Q001) & ID Code(Q002)

I am preparing my arrays at the procedure of the HHID:
PROC HHID

postproc

HHID_OLD=HHID;
OLD_CASE=
loadcase(KENYA_TEST_DICT,HHID_OLD);
if not OLD_CASE then
    
errmsg("HHID DID NOT EXIST IN 2011 SURVEY");
else
    
// lookup old household members
    do hhnum=1 while hhnum<20
        
if IDCX_OLD(hhnum) <> notappl then
            a2011RosterCodes(hhnum-
1) = IDCX_OLD(hhnum);
            a2011RosterNames(hhnum-
1) = NAME_OLD(hhnum);
            a2011RosterGender(hhnum-
1) = GENDER_OLD(hhnum);
            a2011RosterAge(hhnum-
1)=AGE_OLD(hhnum);
        
else
            
break;
        
endif;
    
enddo;
    
// new member
    a2011RosterNames(hhnum-1) = "New member - Not In Survey 2011";
    a2011RosterCodes(hhnum-
1) = 98;
    
// indicate that the dynamic value set is complete
    a2011RosterNames(hhnum) = "";
    a2011RosterCodes(hhnum) =
notappl;
    a2011RosterAge(hhnum) =
notappl;
    a2011RosterGender(hhnum-
1) = notappl;

endif;
and then for Id Code I am using the array as below:
PROC HHID

postproc

HHID_OLD=HHID;
OLD_CASE=
loadcase(KENYA_TEST_DICT,HHID_OLD);
preproc
if OLD_CASE then
    
setvalueset(Q002, a2011RosterCodes, a2011RosterNames);
    
set attributes($) assisted on;
endif;
endif;
but can I do the same for the NAME ? I tried to have a code like:

PROC Q001
preproc
if OLD_CASE then
setvalueset(Q001, a2011RosterNames, a2011RosterCodes);
set attributes($) assisted on;
endif;

but I keep getting an error message from the debugger that there is no text for a2011RosterNames. So I guess it has something to do with alphanumerical variables because for all the numerical ones it works fine. So if that is not possible can I use the show function in my code to display the names from the LookUp File?
And one last thing, there might be some households members from the 2011 survey that are not in this current one(2014). Is it possible to create an array based on arrays? Meaning based on the 2011Names from the LookUp file and the 2014Names based on the CAPI application?

Best,
Stavros
Post Reply