samedi 6 février 2021

SAS - make two different dataset based on specific rules

I have a data set looking like this:

Test place      Method       Capacity
Test place A    Normal          450
Test place A    Close contact    23
Test place B    Normal          500
Test place B    Close contact   900
Test place C    Normal           60
Test place C    Close contact   458
Test place D    Normal           47
Test place E    close contact     4

I need to have to datasets based on the value of capacity and method

If capacity is over or equal to 400 for method Normal, then this testplace should be in a dataset called OVER, ALSO the matching testplace but with method close contact should follow with, even though it has a capacity below 400. (e.g. example test place A and B)

For the case of test place C which has a capacity below 400 and its matching test place C close contact has over 400 - these corresponding places should be in the dataset UNDER.

We only consider whether the normal test place is over or under 400 - the close contact for that same test place shall always follow.

In the case for test place D, where it does not have a close contact place - then it should be in the UNDER dataset, as it is under 400.

For a case as test place E, where there is only a close contact, but it is over 400, then it should be in the UNDER dataset, as I dont want a close contact without a normal test place in the over dataset

Can someone help me please?

Aucun commentaire:

Enregistrer un commentaire