I applied a couple of these solutions to the real world scenario. The data is similar to what I posted and a little over 700,000 rows. If we call @gamotte's approach as approach #1 and @PaigeMiller's approach as approach #2.
Where approach #1 sets all variables into a large array and uses whichc function to find and return the array element and value of interest.
and
Where approach # 2 defines multiple smaller arrays and a do loop to find element of interest in one array and return value of interest from second array.
Both solutions are working and returning the same results (at least at first glance). Both solutions are extremely fast and for practical purposes there is no real difference in performance. @PaigeMiller 's approach does seem to be slightly faster on average. I am getting user CPU times around .2 seconds. @gamotte 's solution is getting around .3 seconds user CPU time. This doesn't seem to be significant enough to matter for a user.
I think I like using the smaller, more defined array's in @PaigeMiller 's approach as I find it easier to visualize what is happening in the code. If we add another type of variable to the data, like pet_breed, it would increase the number of elements into one large array. In the real world scenario I started getting confused with which variable was which element in the array. Any thoughts or feedback on this would be appreciated.
Along these lines is there a way to show or display what variable is what array element? I found this code "put (pets[*]) (=/);" Which was helpful, is there anything more explicit that would show array element 1 = variable name?
... View more