Doug Parkhurst Posted January 20, 2021 Share Posted January 20, 2021 I have a field that is all numbers (i.e. 12345) and I need to place the last two digits (i.e. 45) into a field. Likewise, I also need to place the first two digits (i.e. 12) into a seperate field. I need the numbers together, no spaces in between. Im currently using InfoAssist version 8206. Link to comment Share on other sites More sharing options...
NYCBabak . Posted January 20, 2021 Share Posted January 20, 2021 Is the number always the same size or could it sometimes be 2 digits and sometimes 5 digits What format do you want the two separated fields to be Will they be numeric or alpha Are you discarding the number in between the first 2 and last 2 Whats the format of the original field Take a look at the EDIT function as a starting point: https://ecl.informationbuilders.com/rs_dms_7703/index.jsptopic=%2Fpubdocs%2Freporting%2FUsingFunctions%2Fsource%2Fcharacter10.htm Depending on the answers to the above questions you could also use other character functions like DIGITS. https://infocenter.informationbuilders.com/wf8103/index.jsptopic=%2Fpubdocs%2Freporting%2FUsingFunctions%2Fsource%2Ftopic73.htm Link to comment Share on other sites More sharing options...
Doug Parkhurst Posted January 20, 2021 Author Share Posted January 20, 2021 Thanks for the reply. To answer your questions: 1 - its always two digits 2 - the seperate fields will always be numeric 3 - im not discarding the numbers in between 4 - the original field is an integer Link to comment Share on other sites More sharing options...
NYCBabak . Posted January 20, 2021 Share Posted January 20, 2021 DEFINE FILE CAR WHOLE_FLD/I5 WITH CAR=12345; PART1/I2=EDIT(WHOLE_FLD,99); PART2/I2=EDIT(WHOLE_FLD,$$$99); END TABLE FILE CAR PRINT WHOLE_FLD PART1 PART2 BY CAR END Link to comment Share on other sites More sharing options...
Doug Parkhurst Posted January 20, 2021 Author Share Posted January 20, 2021 Thanks for the reply. Is it possible to do this in version 8206 and not use code Can I use a define to set this up Link to comment Share on other sites More sharing options...
NYCBabak . Posted January 20, 2021 Share Posted January 20, 2021 Yes, EDIT has existed for as long as I can remember. You can get to DEFINE in InfoAssist by clicking Data tab. image.png936694 66.9 KB Once youre in the DEFINE dialogue just put the defined fields Ive provided in one at a time. Keep in mind, this dialogue doesnt need the ; because itll add it internally. image.png889511 31.5 KB Link to comment Share on other sites More sharing options...
Douglas Lee 2 Posted January 20, 2021 Share Posted January 20, 2021 OR: DEFINE FILE CAR WHOLE_FLD/I5 WITH CAR=12345; NEWFIELD/A4 = EDIT(WHOLE_FLD,99)||EDIT(WHOLE_FLD,$$$99); END TABLE FILE CAR PRINT WHOLE_FLD NEWFIELD BY COUNTRY END Link to comment Share on other sites More sharing options...
Charles Morris 2 Posted January 21, 2021 Share Posted January 21, 2021 Unless its changed with recent releases, the EDIT under mask function as shown above requires an alphanumeric input string, so you may have to convert a numeric input to alpha first before doing the above examples. All this can be done in IA DEFINEs. If you need the results as numerics you can EDIT them back to numbers since theyre small Link to comment Share on other sites More sharing options...
Doug Parkhurst Posted January 21, 2021 Author Share Posted January 21, 2021 Thanks for the reply, I ended up creating a define that used the LTRIM function with the FPRINT function and moved the integer to alphanumeric then used a second define with a SUBSTRING to pull the two numbers I needed into a seperate field Link to comment Share on other sites More sharing options...
David Beagan Posted January 21, 2021 Share Posted January 21, 2021 @charles.morris in my 8.2.06 I can run the following to do an EDIT under mask function on a numeric input: TABLE FILE GGSALES PRINT SEQ_NO COMPUTE LAST2/A2 = EDIT(SEQ_NO,'$$$99'); END Dont know what the doc says about this. Link to comment Share on other sites More sharing options...
Charles Morris 2 Posted January 21, 2021 Share Posted January 21, 2021 I was looking at server 7708 dm_func doc, I think there is an 8207 version so it may have changed, but thats very unusual for typical IBI behavior. It would certainly have made things easier years ago to not have to do the num-to-alpha convert. Also, in your example, will it return a value if the LAST2 format is I2 vs A2 Babeks example used I formats for everything which prompted the original question. Link to comment Share on other sites More sharing options...
David Beagan Posted January 21, 2021 Share Posted January 21, 2021 I tried with LAST2/I2 and that worked too! I was kind of expecting it not to. I wouldnt be surprised if it has expanded its capabilities over the years. Link to comment Share on other sites More sharing options...
Charles Morris 2 Posted January 22, 2021 Share Posted January 22, 2021 guess I missed that in the release notes or new features docs, or maybe they just snuck it in and didnt bother to tell us old-timers! Link to comment Share on other sites More sharing options...
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now