cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 

Discussions

Solve problems, and share tips and tricks with other JMP users.
%3CLINGO-SUB%20id%3D%22lingo-sub-384699%22%20slang%3D%22en-US%22%20mode%3D%22NONE%22%3Ejoin%20data%20based%20on%20approximate%20time%20stamp%3C%2FLINGO-SUB%3E%3CLINGO-BODY%20id%3D%22lingo-body-384699%22%20slang%3D%22en-US%22%20mode%3D%22NONE%22%3E%3CP%3EI%20have%20two%20data%20tables%20that%20i%20need%20to%20join.%26nbsp%3B%20table%20A%20has%20time%20stamps%20in%20hours%3A%2024%2C%2048%2C%2072%2C%2096%2C....%26nbsp%3B%20table%20B%20has%20online%20data%20with%205%20minute%20intervals%2C%20so%20the%20time%20stamp%20must%20have%20several%20decimal%20places%20to%20capture%20the%20precision%3A%201.000%2C%201.083%2C%201.167%2C%201.250%2C%201.333%2C%201.417%2C%201.500%20etc.%26nbsp%3B%20joining%20B%20to%20A%20works%20well.%20these%20is%20no%20problems%20because%20there%20is%20always%20a%20whole%20number%20match%20of%20time%20stamp%20in%20table%20B%20with%20table%20A.%20so%20for%20all%20of%20A's%20time%20points%20there%20is%20a%20corresponding%20value%20in%20B.%20the%20problem%20is%20that%20some%20times%20table%20A%20ends%20in%20%22120.1%22%20or%20%22120.4%22%20hours%20for%20example.%20This%20means%20that%20the%20join%20fails%20and%20no%20data%20from%20B%20will%20join%20to%20A%20at%20the%20final%20data%20point.%20is%20there%20a%20way%20to%20get%20%22approximate%22%20matches%20like%20the%20way%20VLOOKUP%20works%20in%20excel%3F%20I%20cannot%20simple%20round%20the%20values%20of%20table%20B%20because%20then%20i%20have%20repeating%20values%20(at%20the%200.3%20and%200.8%20intervals)%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3C%2FLINGO-BODY%3E%3CLINGO-LABS%20id%3D%22lingo-labs-384699%22%20slang%3D%22en-US%22%20mode%3D%22NONE%22%3E%3CLINGO-LABEL%3EData%20Blending%20and%20Cleanup%3C%2FLINGO-LABEL%3E%3C%2FLINGO-LABS%3E%3CLINGO-SUB%20id%3D%22lingo-sub-384743%22%20slang%3D%22en-US%22%20mode%3D%22NONE%22%3ERe%3A%20join%20data%20based%20on%20approximate%20time%20stamp%3C%2FLINGO-SUB%3E%3CLINGO-BODY%20id%3D%22lingo-body-384743%22%20slang%3D%22en-US%22%20mode%3D%22NONE%22%3E%3CP%3EAnother%20idea%20that%20you%20might%20wish%20to%20check%20is%20using%20JMP%20Query%20Builder%20to%20do%20%22fuzzy%22%20joins.%3C%2FP%3E%0A%3CP%3EI%20looked%20at%20this%20for%20someone%20that%20wanted%20to%20identify%20chemical%20components%20that%20are%20within%20a%20certain%20range%20of%20mass%20from%20mass%20spectrometry.%3C%2FP%3E%0A%3CP%3EI%20have%20attached%203%20tables%20as%20an%20example.%20The%20Joined%20table%20has%20class%20from%20the%20Ref%20table%20where%20Mass%20in%20the%20Data%20table%20is%20within%20the%20range%20of%20Mass%20Low%20and%20Mass%20High.%3C%2FP%3E%0A%3CP%3EI%20am%20happy%20to%20provide%20more%20guidance%20if%20you%20think%20this%20solution%20would%20be%20useful.%3C%2FP%3E%0A%3CP%3EThis%20is%20how%20the%20fuzzy%20join%20is%20defined%20in%20JMP%20Query%20Builder%3A%3C%2FP%3E%0A%3CP%3E%3CSPAN%20class%3D%22lia-inline-image-display-wrapper%20lia-image-align-inline%22%20image-alt%3D%22Screenshot%202021-05-13%20121130.png%22%20style%3D%22width%3A%20765px%3B%22%3E%3CSPAN%20class%3D%22lia-inline-image-display-wrapper%22%20image-alt%3D%22Screenshot%202021-05-13%20121130.png%22%20style%3D%22width%3A%20765px%3B%22%3E%3Cspan%20class%3D%22lia-inline-image-display-wrapper%22%20image-alt%3D%22Screenshot%202021-05-13%20121130.png%22%20style%3D%22width%3A%20765px%3B%22%3E%3Cimg%20src%3D%22https%3A%2F%2Fcommunity.jmp.com%2Ft5%2Fimage%2Fserverpage%2Fimage-id%2F32810i82EF64C99C04F884%2Fimage-size%2Flarge%3Fv%3Dv2%26amp%3Bpx%3D999%22%20role%3D%22button%22%20title%3D%22Screenshot%202021-05-13%20121130.png%22%20alt%3D%22Screenshot%202021-05-13%20121130.png%22%20%2F%3E%3C%2Fspan%3E%3C%2FSPAN%3E%3C%2FSPAN%3E%3C%2FP%3E%3C%2FLINGO-BODY%3E%3CLINGO-SUB%20id%3D%22lingo-sub-384710%22%20slang%3D%22en-US%22%20mode%3D%22NONE%22%3ERe%3A%20join%20data%20based%20on%20approximate%20time%20stamp%3C%2FLINGO-SUB%3E%3CLINGO-BODY%20id%3D%22lingo-body-384710%22%20slang%3D%22en-US%22%20mode%3D%22NONE%22%3E%3CP%3EHI%2C%3C%2FP%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%0A%3CP%3ECheck%20out%20the%20Loc%20Sorted(%20)%20function.%20It%20can%20be%20used%20to%20perform%20lookups.%3C%2FP%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%0A%3CP%3EFor%20example%2C%20the%20code%20below%20assigns%20letter%20grades%20to%20simulated%20test%20scores.%20That%20is%2C%20using%20a%20lookup%20matrix%20%5B0%2C%2060%2C%2070%2C%2080%2C%2090%5D%2C%20sample%20scores%20of%2085%2C%2067%2C%2099%2C%2092%20and%2089%20are%20assigned%20letter%20grades%20F%2C%20D%2C%20C%2C%20B%20and%20A%20depending%20if%20the%20score%20exceeds%200%2C%2060%2C%2070%2C%2080%20or%2090%2C%20respectively.%20I've%20used%20it%20in%20ways%20analogous%20to%20your%20use%20case.%3C%2FP%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%0A%3CP%3ECheers%2C%3C%2FP%3E%0A%3CP%3EBrady%3C%2FP%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%0A%3CPRE%3E%3CCODE%20class%3D%22%20language-jsl%22%3EWords(%20%22FDCBA%22%2C%20%22%22%20)%5BLoc%20Sorted(%20%5B0%2C%2060%2C%2070%2C%2080%2C%2090%5D%2C%20%5B85%2C%2067%2C%2099%2C%2092%2C%2089%5D%20)%5D%3B%3C%2FCODE%3E%3C%2FPRE%3E%0A%3CP%3E%3CSPAN%20class%3D%22lia-inline-image-display-wrapper%20lia-image-align-inline%22%20image-alt%3D%22brady_brady_0-1620871449883.png%22%20style%3D%22width%3A%20400px%3B%22%3E%3CSPAN%20class%3D%22lia-inline-image-display-wrapper%22%20image-alt%3D%22brady_brady_0-1620871449883.png%22%20style%3D%22width%3A%20400px%3B%22%3E%3Cspan%20class%3D%22lia-inline-image-display-wrapper%22%20image-alt%3D%22brady_brady_0-1620871449883.png%22%20style%3D%22width%3A%20400px%3B%22%3E%3Cimg%20src%3D%22https%3A%2F%2Fcommunity.jmp.com%2Ft5%2Fimage%2Fserverpage%2Fimage-id%2F32807iD7DB04C360820AED%2Fimage-size%2Fmedium%3Fv%3Dv2%26amp%3Bpx%3D400%22%20role%3D%22button%22%20title%3D%22brady_brady_0-1620871449883.png%22%20alt%3D%22brady_brady_0-1620871449883.png%22%20%2F%3E%3C%2Fspan%3E%3C%2FSPAN%3E%3C%2FSPAN%3E%3C%2FP%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%3C%2FLINGO-BODY%3E
Choose Language Hide Translation Bar
tatersalad
Level II

join data based on approximate time stamp

I have two data tables that i need to join.  table A has time stamps in hours: 24, 48, 72, 96,....  table B has online data with 5 minute intervals, so the time stamp must have several decimal places to capture the precision: 1.000, 1.083, 1.167, 1.250, 1.333, 1.417, 1.500 etc.  joining B to A works well. these is no problems because there is always a whole number match of time stamp in table B with table A. so for all of A's time points there is a corresponding value in B. the problem is that some times table A ends in "120.1" or "120.4" hours for example. This means that the join fails and no data from B will join to A at the final data point. is there a way to get "approximate" matches like the way VLOOKUP works in excel? I cannot simple round the values of table B because then i have repeating values (at the 0.3 and 0.8 intervals)

 

2 REPLIES 2

Re: join data based on approximate time stamp

HI,

 

Check out the Loc Sorted( ) function. It can be used to perform lookups.

 

For example, the code below assigns letter grades to simulated test scores. That is, using a lookup matrix [0, 60, 70, 80, 90], sample scores of 85, 67, 99, 92 and 89 are assigned letter grades F, D, C, B and A depending if the score exceeds 0, 60, 70, 80 or 90, respectively. I've used it in ways analogous to your use case.

 

Cheers,

Brady

 

Words( "FDCBA", "" )[Loc Sorted( [0, 60, 70, 80, 90], [85, 67, 99, 92, 89] )];

brady_brady_0-1620871449883.png

 

Phil_Kay
Staff

Re: join data based on approximate time stamp

Another idea that you might wish to check is using JMP Query Builder to do "fuzzy" joins.

I looked at this for someone that wanted to identify chemical components that are within a certain range of mass from mass spectrometry.

I have attached 3 tables as an example. The Joined table has class from the Ref table where Mass in the Data table is within the range of Mass Low and Mass High.

I am happy to provide more guidance if you think this solution would be useful.

This is how the fuzzy join is defined in JMP Query Builder:

Screenshot 2021-05-13 121130.png

Recommended Articles