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-8402%22%20slang%3D%22en-US%22%20mode%3D%22NONE%22%3ESubstring%2C%20Munger%2C%20or...%20formula%3F%3C%2FLINGO-SUB%3E%3CLINGO-BODY%20id%3D%22lingo-body-8402%22%20slang%3D%22en-US%22%20mode%3D%22NONE%22%3E%26lt%3Bmeta%20http-equiv%3D%22Content-Type%22%20content%3D%22text%2Fhtml%3B%20charset%3DUTF-8%22%20%2F%26gt%3B%3CP%3EI%E2%80%99ve%20been%20wrestling%20with%20a%20database%20problem%20for%20a%20couple%20of%20days%20and%20I%E2%80%99m%20stumped.%26nbsp%3B%20I%20wonder%20if%20any%20of%20you%20might%20be%20able%20to%20help%3F%26nbsp%3B%20I%E2%80%99m%20dealing%20with%20several%20hundred%20tables%20that%20include%20records%20for%20wildlife%20sites%26nbsp%3B%20For%20each%20record%2C%20there%20is%20a%20field%20that%20includes%20the%20site%20identifier%20appended%20to%20the%20path%20in%20my%20computer%20and%20a%20.tif%20suffix%2C%20like%20these%20examples%3A%3C%2FP%3E%3CP%3E%3C%2FP%3E%3CP%3E%3CSPAN%20style%3D%22color%3A%20black%3B%22%3EE%3A%5CWork%5COWI%5CLIDAR%5COwl_Landscapes%5Cp99%5Cp99sliced%5Crnd_SI_PK_%3CEM%3E%3CSTRONG%3EUR3%3C%2FSTRONG%3E%3C%2FEM%3E.tif%20%3C%2FSPAN%3E%3C%2FP%3E%3CP%3E%3CSPAN%20style%3D%22color%3A%20black%3B%22%3EE%3A%5CWork%5COWI%5CLIDAR%5COwl_Landscapes%5Cp99%5Cp99sliced%5Crnd_SI_PK_%3CEM%3E%3CSTRONG%3E20100195%3C%2FSTRONG%3E%3C%2FEM%3E.tif%20%3C%2FSPAN%3E%3C%2FP%3E%3CP%3E%3CSPAN%20style%3D%22color%3A%20black%3B%22%3E%3CBR%20%2F%3E%3C%2FSPAN%3E%3C%2FP%3E%3CP%3E%3CSPAN%20style%3D%22color%3A%20black%3B%22%3E%5BSite%20identifier%20in%20bold%20italics%5D%20%3CBR%20%2F%3E%3C%2FSPAN%3E%3C%2FP%3E%3CP%3E%3C%2FP%3E%3CP%3E%3CSPAN%20style%3D%22font-size%3A%2011.0pt%3B%20font-family%3A%20'Calibri'%2C'sans-serif'%3B%20color%3A%20black%3B%22%3EI%20need%20to%20create%20a%20new%20field%20in%20each%20table%20that%20holds%20only%20the%20site%20identifier%2C%20minus%20the%20path%20and%20.tif%20suffix.%26nbsp%3B%20I%E2%80%99m%20somewhat%20familiar%20with%20substring%20and%20Munger%20formulas%20that%20I%20have%20used%20to%20extract%20parts%20of%20strings.%26nbsp%3B%20But%20in%20this%20case%2C%20some%20site%20identifiers%20have%20mixed%20text%2Fnumeric%20characters%20and%20the%20string%20length%20is%20different%20among%20different%20records%2C%20so%20I%20can%E2%80%99t%20get%20these%20formulas%20to%20work.%26nbsp%3B%20Can%20someone%20offer%20advice%3F%3C%2FSPAN%3E%3C%2FP%3E%3CP%3E%3CSPAN%20style%3D%22font-size%3A%2011.0pt%3B%20font-family%3A%20'Calibri'%2C'sans-serif'%3B%20color%3A%20black%3B%22%3E%3CBR%20%2F%3E%3C%2FSPAN%3E%3C%2FP%3E%3CP%3E%3CSPAN%20style%3D%22font-size%3A%2011.0pt%3B%20font-family%3A%20'Calibri'%2C'sans-serif'%3B%20color%3A%20black%3B%22%3EDave%3C%2FSPAN%3E%3C%2FP%3E%3C%2FLINGO-BODY%3E
Choose Language Hide Translation Bar
owiuser
Level I

Substring, Munger, or... formula?

I’ve been wrestling with a database problem for a couple of days and I’m stumped.  I wonder if any of you might be able to help?  I’m dealing with several hundred tables that include records for wildlife sites  For each record, there is a field that includes the site identifier appended to the path in my computer and a .tif suffix, like these examples:

E:\Work\OWI\LIDAR\Owl_Landscapes\p99\p99sliced\rnd_SI_PK_UR3.tif

E:\Work\OWI\LIDAR\Owl_Landscapes\p99\p99sliced\rnd_SI_PK_20100195.tif


[Site identifier in bold italics]

I need to create a new field in each table that holds only the site identifier, minus the path and .tif suffix.  I’m somewhat familiar with substring and Munger formulas that I have used to extract parts of strings.  But in this case, some site identifiers have mixed text/numeric characters and the string length is different among different records, so I can’t get these formulas to work.  Can someone offer advice?


Dave

1 ACCEPTED SOLUTION

Accepted Solutions
Jeff_Perkinson
Community Manager Community Manager

Re: Substring, Munger, or... formula?

Hi Dave,

Try the Word() function.

     Word( -2, :Column 1, "_." )

That formula will get you what you want. The "-2" argument says that the Word() function should find the second to last word using _ and . as delimiters.

-Jeff

-Jeff

View solution in original post

5 REPLIES 5
rw9
rw9
Level I

Re: Substring, Munger, or... formula?

Hi,

Check out perl regular expressions - base SAS = prxparse, prxchange etc.  Should be able to do this straightforward with that.

Just to add, it looks like you have a fixed start?  If so then tranwrd(substr(string,fixed_start),".tif","") should also work.

reeza
Level III

Re: Substring, Munger, or... formula?

I don't think standard SAS functions work in JMP.

Substring is what you're looking for.

The starting point is fixed, find the location of the period and substring between those. 

Re: Substring, Munger, or... formula?

Are you using JMP or Base SAS to read these files?

Jeff_Perkinson
Community Manager Community Manager

Re: Substring, Munger, or... formula?

Hi Dave,

Try the Word() function.

     Word( -2, :Column 1, "_." )

That formula will get you what you want. The "-2" argument says that the Word() function should find the second to last word using _ and . as delimiters.

-Jeff

-Jeff
owiuser
Level I

Re: Substring, Munger, or... formula?

Thank you everybody! Jeff's suggestion worked perfectly.  Dave

Recommended Articles