Question: Bit of a tricky question. I need method to systematically to group,order, and create new rows of data. There are three 4 levels of stratification (c1,c2,c3,c4) and a "score" value for each iteration of stratification. It is a bit hard to articulate, so I will give you the HAVE and WANT tables

Here are the datalines tables for easy manipulation.

```
data HAVE;
   input CLASS $ FUR_COLOR $ FAMILY $ SPECIES $ NO_IN_CAPTIVITY;
   datalines;
MAMMAL BLACK WHALE KILLER_WHALE 2 
MAMMAL BLACK FELINE PUMA 3
MAMMAL BLACK APE CHIMP 5
MAMMAL BLACK APE GORILLA 3
MAMMAL BLACK APE BONOBO 3
MAMMAL RED APE ORANGUTAN 2
;
RUN;

data WANT;
   input C1 $ C2 $ C3 $ C4;
   datalines;
MAMMAL . BLACK                .
MAMMAL WHALE KILLER_WHALE 2
MAMMAL . BLACK .
MAMMAL FELINE PUMA 3
MAMMAL . BLACK .
MAMMAL APE CHIMP 5
MAMMAL APE GORILLA 3
MAMMAL APE BONOBO 3
MAMMAL . RED .
MAMMAL APE ORANGUTAN 2
;
RUN;

```

Answer: 
This code should work

```
import CoreBluetooth

func foo(advertisementData: [String : AnyObject]) {

    if let
        list = advertisementData["kCBAdvDataServiceUUIDs"] as? [AnyObject]
        where (list.contains { ($0 as? CBUUID)?.UUIDString == "C9CAB9B8-3ABF-4043-A5AF-9AD00C6074D5" }) {
        print("Found")
    }
}

```
At first, you could just limit your scanning results to the specific Service UUID.
Might ensure in very crowded bluetooth areas that you will not be spammed with all the others in your CBCentralManager delegate.

```
let serviceUUID = CBUUID(string: "C9CAB9B8-3ABF-4043-A5AF-9AD00C6074D5")
self.centralManager?.scanForPeripherals(withServices: [serviceUUID], options: [CBCentralManagerScanOptionAllowDuplicatesKey: true])

```

Or in your [CBPeripheralDelegate](https://developer.apple.com/documentation/corebluetooth/cbcentralmanagerdelegate/1518937-centralmanager):

```
func centralManager(_ central: CBCentralManager,
                        didDiscover peripheral: CBPeripheral,
                        advertisementData: [String : Any],
                        rssi RSSI: NSNumber)
    {
        print("peripheral: \(peripheral)")
        print("     \(advertisementData)")
        print (RSSI)

        if let uuids = advertisementData[CBAdvertisementDataServiceUUIDsKey] as? [AnyObject],
            uuids.contains(where:{ ($0 as? CBUUID)?.uuidString == "C9CAB9B8-3ABF-4043-A5AF-9AD00C6074D5" }) {
            central.connect(peripheral, options: nil)
        }
    }

```