Question: I want to store key value pair in data base where key is a list of Integers or a set of Integers.

The use case that I have has the below steps

1. I will get a list of integers
2. I will need to check if that list of integers (as a key) is already present in the DB
3. If this is present, I will need to pick up the value from the DB

There are certain computations that I need to do if the list of integers (or set of integers) is not there in the DB already, if this there then I just want to pass the value and avoid the computations.

I am thinking of keeping the data in a key value store but I want the key to be specifically a list or set of integers.

I have thought about below options 

**Option A**

Generate a unique hash for the list of integers and store that as key in key/value store

Problem:
I will have hash collision which will break my use case. I believe there is no way to generate hash with uniqueness 100% of the time.

This will not work.

If there is away to generate a unique hash (100%) times then that is the best way. 

**Option B**

Create an immutable class with List of integers or Set of integers and store that as a key for my key value store.

Please share any feasible ways to achieve the need.

Answer: 
The values of your variables are longer than the 8 bytes you are allowing for them. The UTF-8 characters can use up to 4 bytes each. Looks like some of them are getting truncated in the middle, so you get an invalid UTF-8 code. 

Just define longer lengths for your variables instead of letting SAS use the default length of 8. In general it is best to explicitly define your variables with a LENGTH or ATTRIB statement. Instead of forcing SAS to guess how to define them based on how you first use them in other statements like INPUT, FORMAT, INFORMAT or assignment.

```
data wk01;
  infile '/folders/myfolders/data/test_csv.txt' dsd dlm=',' truncover ;
  length firstcol $8 secondcol $30 thirdcol $30 therest $100;
  input firstcol secondcol thirdcol therest;
run ;

```
I think what you have is a mixed encoding problem. What's essentially happening is that after the first 5 characters which are in ASCII, it changes to UTF8. The commas are getting mixed up in this soup and your standard delimiter gets a bit confused here. You need some manual coding like this to deal with it I think :

```
data wk01;
  infile "test.csv" lrecl=1000 truncover firstobs=1;
  input text $utf8x70.;

  firstcomma =  findc(text,',', 1);
  secondcomma =  findc(text,',', firstcomma + 1);
  thirdcomma =  findc(text,',', secondcomma + 1);
  fourthcomma =  findc(text,',', thirdcomma + 1);

  length firstcol $5;
  length secondcol $30;
  length thirdcol $1;
  length fourthcol $30;

  firstcol= substr(text,1, firstcomma - 1);
  secondcol = substr(text, firstcomma + 1, (secondcomma -firstcomma-1 ));
  thirdcol = substr(text, secondcomma + 1, (thirdcomma - secondcomma - 1));
  fourthcol = substr(text, thirdcomma + 1);
run;

```

Probably there is a cleaner way to do it, but this is the quick and dirty method I could come up at 2 AM :)