t-test & chi²- how to import data the right way?


It would be nice if someone could help me out.
I have two excel files.

One in the form of (patientdata, 500 patients):

The other one in the form of (blood test measurements of the patients, 16000 measurements):
The patientcode is the only thing connecting the information of the two files.

I would like to group the data available in the first file (patientdata) according to the PHOS measurement in file 2:
Group 1: The patient needs to have at least one "PHOS" measurement ('Analysecode') and at least one of those measurements ('Reply') must be <0.80
Group 2: The patient needs to have at least one "PHOS" measurement ('Analysecode') and all of those ('Reply') must be >=0.80


Afterwards I would like to analyze the data with Chi² and unpaired t-test*. As a result I would like to get the following information:

Excel 41.PNG

I simply do not know how to make this happen, since the excel data is so different. I tried grouping & combining the data in excel and using a pivot table, but this was the wrong thought.

Would be really kind, if someone could help me.
Thank you


*I would like to use chi-square test for dichotomous data (Scoringsystem B will be '1-2 = good' and '3-5 = bad) and unpaired t-test for the rest.
Last edited: