SUMMARY ROSTER

Discussions about CSEntry
PHINOJOSA
Posts: 45
Joined: April 16th, 2023, 10:31 pm

SUMMARY ROSTER

Post by PHINOJOSA »

Good morning

I am working on a project in which I have to enter information about food consumption on an individual basis in a household.

As a first step to ask about housing, household, type of food (breakfast, lunch or dinner), time etc. and after that for each type of food add the preparations in a roster in which are the ingredients of each preparation, I thought to make a roster for each preparation (in the image I put roster1, roster2, etc).
Imagen 1.PNG
Imagen 1.PNG (92.76 KiB) Viewed 580838 times

Well after that you should summarize each preparation in a single row as shown in the image, and then summarize in a new roster for each preparation as shown in the image I don't know how to do that.
Imagen 2.PNG
Imagen 2.PNG (21.26 KiB) Viewed 580838 times

I will be advancing as far as my knowledge allows me and when I have an advance I will upload it here so that you can help me,

I need your help, thank you
justinlakier
Posts: 152
Joined: November 21st, 2022, 4:41 pm

Re: SUMMARY ROSTER

Post by justinlakier »

Hi,

From your example, each row in a roster in step 2 will share an Orden, Preparacion, and Tipo De Preparacion. They will only start differing within a roster once you get to Ingredientes.If you have the information from step 2 in a roster, you can loop through it using logic to sum and set the information for the new summary roster.
For instance, you could put this in the preproc of the Summary Roster's Resumen Roster variable to loop through all items in the other Roster which share an Orden. This will fill every row with the information from the Orden of the same number.
numeric RosterNum = curocc();
numeric IngredientNum = 0;
numeric PesoTotal = 0;
for ROSTER_NAME where ROSTER_NUM = RosterNum do
   
SUM_ROSTER = ROSTER_NUM;
    SUM_ORDEN = ORDEN;
    SUM_PREP = PREPARACION;
    SUM_TIP = TIPO_DE_PREPARACION;
    IngredientNum = IngredientNum + 1;
    PesoTotal = PesoTotal + PESO;
enddo;
SUM_INGREDIENT_NUM = IngredientNum;
SUM_PESO_TOTAL = PesoTotal ;
You can also set the other summary variables from their counterparts in the step 1 roster here (Vivienda, Hogar, Comida, Hora, Lugar, etc), as they should all be duplicates within a roster. This should allow you to loop over and summarize your other rosters in a new roster. Please let us know if you have any further questions.

Hope that helps,
Justin
PHINOJOSA
Posts: 45
Joined: April 16th, 2023, 10:31 pm

Re: SUMMARY ROSTER

Post by PHINOJOSA »

Dear friends

Thanks for the advice, but I could not get to that point I have advanced a little bit attached zip file.

I send in this reply the structure I want to do, as I must first enter the meals of the day (step 1), then enter MEAL 1 and record all the preparations (step 2) and then enter PREPARATION 1 OF MEAL 1 and record all the ingredients of that preparation, then I must enter all the preparations of meal 1, when I finish all the preparations of meal 1, go to MEAL 2 and do the same process.
Estructura.png
Estructura.png (49.83 KiB) Viewed 580795 times
Previously I have thought to make several ROSTER, but it would be many variables, I thought it could be a ROSTER for each MEAL and in that case it could be a maximum of 7 ROSTER.

But I have encountered a problem if it was only 1 ROSTER and I enter MEAL 1. PREPARATION 1, INGREDIENT 1 and all the variables and at the end ask (1 = add ingredient, 2 = leave the roster) and 3 = enter another preparation.

in the case that ADD = 3, the name of the preparation will be copied since the name of the preparation was entered in step 2, and enter all the data of this new preparation then if you add more ingredients copy the data to where to look for the ingredients.

And at the end summarize in a ROSTER all the other ROSTERS.
Imagen 3.png
Imagen 3.png (60.23 KiB) Viewed 580795 times
Imagen 4.png
Imagen 4.png (172.5 KiB) Viewed 580795 times
I attach images and file of the progress so that you can help me, I hope I have explained better what I want to do and the problems I have.

There are some problems in the code that surely you who know much more than me, can improve the code maybe, I hope your help.

When I thought of making several roster I took the count and it would be like 49 roster and that's a lot.

And when exporting to SPSS it does not come out as I wish.

Thank you very much for your help.
Last edited by PHINOJOSA on November 2nd, 2023, 9:03 am, edited 1 time in total.
PHINOJOSA
Posts: 45
Joined: April 16th, 2023, 10:31 pm

Re: SUMMARY ROSTER

Post by PHINOJOSA »

The attachment has been removed, as it is an old version.
Last edited by PHINOJOSA on November 9th, 2023, 3:13 pm, edited 1 time in total.
justinlakier
Posts: 152
Joined: November 21st, 2022, 4:41 pm

Re: SUMMARY ROSTER

Post by justinlakier »

Could you clarify some points on how this data is to be collected in the field? Will one person be surveyed to gather the data for the household, or will every member of a household be interviewed separately? There do not seem to be any Viviendad/Hogares/etc identifiers in the survey which allow linking to either an existing Household or a Person within a household. Are interviewees expected to keep a journal of past meals, preparations, and ingredients, or will they attempt to remember as much as they can? Is your example accurate that an interview should capture a maximum of 7 Meals, each meal having a maximum of 7 Preparations, with each Preparation having a maximum of 20 Ingredients? Knowing these informs how the design needs to be implemented.

Thank you,
Justin
PHINOJOSA
Posts: 45
Joined: April 16th, 2023, 10:31 pm

Re: SUMMARY ROSTER

Post by PHINOJOSA »

Hello Justin

Thank you for the consultation, in fact the example I sent does not have the details of housing, home, etc. First, the house is identified, then the home and finally a person from the home who would be chosen randomly to whom the questionnaire would be applied. of food consumption that would be everything you remember in the last 24 hours.

Once the person is identified, the first thing they will be asked to do is list all the foods, which could be from 1 to 7, once they finish listing the foods. We will have to go to meal 1 and then ask him to list all the preparations, for example if the meal was breakfast the preparations could be papaya juice, bread with egg and some toast. When I finish listing the preparations, we will have to go to the first preparation, which for this example is papaya juice, and look for each of the ingredients that this preparation will have (sugar, water, papaya, strawberry), look for the first one and fill in all the data that is shown. Will they then ask at the end of the line to ask to add another ingredient? We will have to say yes and it should be possible to copy all the data they have in common and so on until we finish with all the ingredients of the first preparation.

Once finished with preparation 1, at the end it will ask to add another ingredient, mark "Other preparation" and in the next row of the ROSTER you should fill in the name of preparation 2 (bread with egg) and fill in your data until the end and For the second ingredient, repeat the common data from preparation 2 and so on until all the ingredients of preparation 2 are finished and then to preparation 3 (toast) and after finishing, mark at the end do not add more ingredients and you should go to the meal 2 and repeat the entire procedure until meal 7. but in case there are 2 until meal 2, or if there are up to 3 meals until meal 3, until the meals listed in the first phase.

Currently the difficult thing is that the common data of the preparations is repeated and that when the preparation changes, it pulls the name of the preparation.

Another point is that at the end a summary should be made at the level of preparation, food as I sent the image in the first posts.

I really appreciate the interest of those who downloaded the file to help me,

I am attaching a new version, but I have some problems, such as if I save partially, when I return to the survey I must re-enter the ingredients from the beginning, and another problem is that if I find the ingredient the first time in BUSCAR1, it must be skipped. in front of CODE1 and enter the code that corresponds to the ingredient, but if there is no ingredient, you must look for the equivalent ingredient in R1P110 then go to R1P111 and then to CODE1 but with the ingredient code of R1P110 but it does not work.

Imagen 5.png
Imagen 5.png (13.35 KiB) Viewed 580598 times
Attachments
R24_3.rar
(318.31 KiB) Downloaded 1294 times
sherrell
Posts: 397
Joined: April 2nd, 2014, 9:16 pm
Location: Washington, DC

Re: SUMMARY ROSTER

Post by sherrell »

Thank you for the consultation, in fact the example I sent does not have the details of housing, home, etc. First, the house is identified, then the home and finally a person from the home who would be chosen randomly to whom the questionnaire would be applied. of food consumption that would be everything you remember in the last 24 hours.
Is there a second application that runs before this? Or are you stripping down a single application to just try and show us the relevant parts? Which I appreciate, but I'm also having a hard time understanding how an analyst will make sense of all this data and be able to link up persons within a household properly.

What happens if several people in a household (HH) eat the same prepared dish (whether or not the dish was prepared in the HH or purchased outside the HH)--are they each supposed to list all the ingredients? If so, how would a person know how that information if they did not prepare the dish? And since they will likely give different answers, the data becomes less meaningful/possibly meaningless. I was hoping a food diary was being created so that when an interviewer arrived at the HH, the interviewer could log all the common meals (and their ingredients), and HH members could chose from those items in addition to any other food items listed.

I get the impression that for each food item listed on Form PC1 (C1P#), you want a roster of possible ingredients for it. If so, then the 20 roster items in record INC1P1 should exist for each food being entered on the PC1 form. Which means you either need to associate separate rosters for each of the 7 food items listed on form PC1, or you need to create a 2-level dictionary and allow each food item to have multiple "children". But that's more complicated, so I would suggest you create a separate roster for each food item...which still doesn't fix the issue of how to "marry up" the same dishes that are eaten by more than one person in the HH. That is something we don't have staff resources to answer, maybe others on the forum can.

Item 1:
when I return to the survey I must re-enter the ingredients from the beginning
You need to add a check before making your selcase call to see if you're processing an "in advance" call (i.e., what resuming entry where you left off will do when you restart the app). So prior to your selcase call, you need to wrap all of that within a:
if ! inAdvance() and length(strip($))=0 then

   
// selcase calls/other stuff
   
endif;
Item 2: For all those subscript warnings you're getting because you're skipping to a field without giving the index, you should either skip to the form itself, or (preferred) use the "endgroup" command, which will terminate entry for the form you're on. By skipping to the first field on another form, any postproc logic for (a) the field you're on, (b) the form you're on, (c) the preproc logic on the form you're skipping to, and (d) the preproc logic for the roster that R1P101 sits within, will all be skipped over. This might be something you intended, but likely not. At the very least the starting logic for the destination form and roster should likely be run.

Item 3:
We will have to say yes and it should be possible to copy all the data they have in common and so on until we finish with all the ingredients of the first preparation.
I'm not sure exactly what you mean here. Which data will you be copying and to where? Please cite variable names.

Item 4:
and another problem is that if I find the ingredient the first time in BUSCAR1, it must be skipped. in front of CODE1 and enter the code that corresponds to the ingredient, but if there is no ingredient, you must look for the equivalent ingredient in R1P110 then go to R1P111 and then to CODE1 but with the ingredient code of R1P110 but it does not work.
There is nothing named CODE1. Do you mean CODIGO1? In PROC BUSCAR1 the same selcase call is being made in the followup PROC R1P110...so I'm not sure why anything will be different on the second call. And it sounds like you're trying to go backwards (return to "CODE"1), yet I don't see any logic to support that (your application did not compile due to an incomplete logic block in PROC CODIGO1, so I don't know if you sent us the correct application, but maybe that's where this was happening?). Also in PROC BUSCAR there are a several assignments taking place after the "skip to CODIGO1;" call, but none of that logic will be executed of course due to the skip.

Sherrell
PHINOJOSA
Posts: 45
Joined: April 16th, 2023, 10:31 pm

Re: SUMMARY ROSTER

Post by PHINOJOSA »

Good afternoon

Sorry for the delay in responding to the queries. I appreciate Sherrell's interest in helping me, now I'm going to answer your questions to have the complete picture.

Q1.
Is there a second application that runs before this? Or are you stripping down a single application to just try and show us the relevant parts? Which I appreciate, but I'm also having a hard time understanding how an analyst will make sense of all this data and be able to link up persons within a household properly.
This questionnaire has a part with sociodemographic data, for that reason I have omitted that part in this explanation and I apologize for the case, the fundamental and main part being the collection of consumption data, I understand the doubt but this questionnaire will only be applied to one person per household so there will be no problem linking consumption data.

Q2.
What happens if several people in a household (HH) eat the same prepared dish (whether or not the dish was prepared in the HH or purchased outside the HH)--are they each supposed to list all the ingredients? If so, how would a person know how that information if they did not prepare the dish? And since they will likely give different answers, the data becomes less meaningful/possibly meaningless. I was hoping a food diary was being created so that when an interviewer arrived at the HH, the interviewer could log all the common meals (and their ingredients), and HH members could chose from those items in addition to any other food items listed.
I understand the doubt, the people who prepare the food will generally be interviewed, therefore they will have knowledge of the ingredients that have been used in the preparation of the food.

If a person who has not prepared the food is interviewed, they will be asked how they would have prepared it and thus we would have some reference values. This questionnaire so far has 2 lists of queries.

The first a list of ingredients and a second list of portion sizes with which it is expected to obtain the net weight of each ingredient according to the portion.

Q3.
You need to add a check before making your selcase call to see if you're processing an "in advance" call (i.e., what resuming entry where you left off will do when you restart the app). So prior to your selcase call, you need to wrap all of that within a:

Code: Select all

if ! inAdvance() and length(strip($))=0 then
    // selcase calls/other stuff
endif;
Add the collection lines and that problem was effectively solved, but if it does not find the ingredient, the fields are skipped and when returning from a partial save, some fields turn lead-colored, which we know will not be considered in the data.

And now it's back to another WEIGHT field.
Imagen 3.PNG
Imagen 3.PNG (31.37 KiB) Viewed 580152 times
Q4.
I'm not sure exactly what you mean here. Which data will you be copying and to where? Please cite variable names.
The data that must be repeated are those enclosed in a blue rectangle; these data are repeated for each preparation. at the end of the row ask add more ingredients? and when answering if those data from the beginning, being from the same preparation, should be repeated and then from the search variable the data changes.

This process must be done every time the preparation is changed, which as is known can be a maximum of 7 preparations.
Imagen 4.png
Imagen 4.png (34.63 KiB) Viewed 580152 times
Q5.
There is nothing named CODE1. Do you mean CODIGO1? In PROC BUSCAR1 the same selcase call is being made in the followup PROC R1P110...so I'm not sure why anything will be different on the second call. And it sounds like you're trying to go backwards (return to "CODE"1), yet I don't see any logic to support that (your application did not compile due to an incomplete logic block in PROC CODIGO1, so I don't know if you sent us the correct application, but maybe that's where this was happening?). Also in PROC BUSCAR there are a several assignments taking place after the "skip to CODIGO1;" call, but none of that logic will be executed of course due to the skip.
I am sorry for what happened, I must have confused the file when uploading, now I am sending a progress, it is not much because, as you know, given my queries I have been stuck without being able to move forward.

R24_3.zip
(1.11 MiB) Downloaded 1409 times

After I can solve the conflicts that I have had, I will move on to the second phase, which will be to do the same but for the rest of the meals, which are up to 7 maximum, and as the third phase, summarize the data in a new roster as I explained at the beginning of this post. where each row is a preparation.

Thank you very much in advance, I hope you can help me soon.
sherrell
Posts: 397
Joined: April 2nd, 2014, 9:16 pm
Location: Washington, DC

Re: SUMMARY ROSTER

Post by sherrell »

Cases 0010101 and 0020101: When I tried to review these cases I am stopped at field R1P102, as the field displays an asterisk. This happens when the dictionary is changed and the case no longer aligns with the prior version of the dictionary. Changes that can cause this are when you modify dictionary fieldwidths, or add or delete dictionary variables. When this happens you should generally discard any data files that were created with it as you will have this problem.

Case 0030101: When I tried to resume entry I am stopped at the fields that are making selcase calls. You need to add in the logic I cited in my prior message in order to avoid this happening; i.e., you need to add:

if ! inAdvance() and length(strip($))=0 then

// selcase calls/other stuff

endif;

Could you please add this logic in the appropriate places before resubmitting your application?

>After I can solve the conflicts that I have had,

Could you please clarify what conflict, other than the inability to advance due to the missing logic I just mentioned, you are having?

Thanks, Sherrell
PHINOJOSA
Posts: 45
Joined: April 16th, 2023, 10:31 pm

Re: SUMMARY ROSTER

Post by PHINOJOSA »

Good afternoon
Cases 0010101 and 0020101: When I tried to review these cases I am stopped at field R1P102, as the field displays an asterisk. This happens when the dictionary is changed and the case no longer aligns with the prior version of the dictionary. Changes that can cause this are when you modify dictionary fieldwidths, or add or delete dictionary variables. When this happens you should generally discard any data files that were created with it as you will have this problem.
I apologize for that, that data was indeed from a long time ago when I still had few variables. I shouldn't have included it in the previous shipment.
Case 0030101: When I tried to resume entry I am stopped at the fields that are making selcase calls. You need to add in the logic I cited in my prior message in order to avoid this happening; i.e., you need to add:

if ! inAdvance() and length(strip($))=0 then
// selcase calls/other stuff
endif;
I have added the code that you sent, but I have noticed some changes in this regard, before I could write directly in the search field and when I hit enter the results that matched the search would appear, now after adding the code you must first hit enter to enter to search and filter.

but when returning after a partial save, the previously entered data is preserved.
Could you please clarify what conflict, other than the inability to advance due to the missing logic I just mentioned, you are having?
Well, the problems I currently have are when to change the preparation, that is, go from preparation 1 to preparation 2 of food 1.

When I finish entering the first record of the first preparation and adding the second ingredient, all the data must be re-entered up to R1P107 which, being part of the same preparation, should be the same, so I want that data to automatically are the same as they belong to the first preparation and from then on the data may be different. until moving on to another preparation where everything will be entered in the first record.

I will upload an image showing how the table (roster) should look. so you can understand me better.
Imagen 5.png
Imagen 5.png (34.53 KiB) Viewed 580095 times

As seen in the image, the data that is framed on the left is repeated per preparation, and from then on the data varies according to each ingredient.

The names of the preparations must be automatically copied from the C1 fields (which can be up to 7 preparations) each time a new preparation is entered.
Imagen 6.png
Imagen 6.png (55.83 KiB) Viewed 580095 times

thanks for your help

R24_3.zip
(1.14 MiB) Downloaded 1378 times
Post Reply