Hello, I am brand new to Jmp and using the script to try to rearrange a dataset. Currently I have a dataset that is like follows:
| ID | Lab | Lab Value | Lab date and time | Medication |
| A | Hgb | 12 | 10/5/16 6:00 AM | tylenol |
| A | Cr | 1 | 10/5/16 6:00 AM | tylenol |
| A | K | 4 | 10/5/16 6:00 AM | tylenol |
| B | K | 3.7 | 11/6/02 4:00 AM | aspirin |
| B | K | 4.5 | 11/6/02 7:00 AM | aspirin |
| B | Cr | 1.2 | 11/6/02 7:00 AM | aspirin |
| B | Hgb | 14 | 11/6/02 7:00 AM | aspirin |
| C | Cr | 1.5 | 1/15/09 6:30 AM | vitamin D |
| C | Hgb | 12 | 1/15/09 6:30 AM | vitamin D |
| C | Hgb | 9 | 1/15/09 9:30 AM | vitamin D |
I would like each ID to be a single row with columns for each individual lab. For any ID there may be duplicates of different labs, but I would like to keep all values for each lab and make them a separate column. I was thinking of making a count variable after sorting by ID and lab so that I could combine and make a variable that would be Hgb1, Hgb2, but I do not know how to do this. I also do not know how to transpose as I am picturing.
| ID | Hgb1 | Lab date and time | Hgb2 | Lab date and time | Cr1 | Lab date and time | Cr2 | Lab date and time | K1 | Lab date and time | K2 | Lab date and time | Medication |
| A | 12 | 10/5/16 6:00 AM | | | 1 | 10/5/16 6:00 AM | | | 4 | 10/5/16 6:00 AM | | | tylenol |
| B | | | | | | 11/6/02 7:00 AM | | | 3.7 | 11/6/02 4:00 AM | 4.5 | 11/6/02 7:00 AM | aspirin |
I would appreciate any help.
Thank you!!!