<?xml version="1.0" encoding="UTF-8"?>
<rss xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" xmlns:taxo="http://purl.org/rss/1.0/modules/taxonomy/" version="2.0">
  <channel>
    <title>topic Re: Using an array in user defined function in SAS Procedures</title>
    <link>https://communities.sas.com/t5/SAS-Procedures/Using-an-array-in-user-defined-function/m-p/85035#M24318</link>
    <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Ok, I had looked in there earlier this morning, and there is no ebcdic entry in sashelp.host.&amp;nbsp; I get this error...&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-size: 8pt;"&gt;&amp;nbsp; &lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;ERROR: Entry EBCDIC.TRANTAB not found in catalog SASHELP.HOST.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;However, I was able to view the ebcdic translation tables using proc trantab, so it must be somewhere, I just can't find it.&amp;nbsp; Just to make sure I was looking in the correct place, I replaced ebcdic with ascii, which is in my sashelp.host, in your filename statement above, and it worked as it should. &lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
    <pubDate>Wed, 18 Apr 2012 17:42:31 GMT</pubDate>
    <dc:creator>gsnidow</dc:creator>
    <dc:date>2012-04-18T17:42:31Z</dc:date>
    <item>
      <title>Using an array in user defined function</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/Using-an-array-in-user-defined-function/m-p/85010#M24293</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Greetings all.&amp;nbsp; This is a follow up to my last question here, &lt;A _jive_internal="true" href="https://communities.sas.com/thread/34254"&gt;https://communities.sas.com/thread/34254&lt;/A&gt; where I was trying to convert between ascii and ebcdic values.&amp;nbsp; However, this is a new problem I am having, so I will leave that one alone.&amp;nbsp; As it is right now, I am able to use an array in a data step to provide the lookup values of ascii to ebcdic.&amp;nbsp; Basically I am looking at each set of 2 characters in the ascii string, and returning the ebcdic value, which is contatanated to itself to produce the full ebcdic string.&amp;nbsp; Below is the code&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;/* set up an accounts table to hold the ascii string.&amp;nbsp; In reality there would be millions of observations,&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp; and the ascii_string could be up to 512 characters in length.*/&lt;/P&gt;&lt;P&gt;data Accounts;&lt;/P&gt;&lt;P&gt; input ID ASCII_STRING $3-30;&lt;/P&gt;&lt;P&gt; datalines;&lt;/P&gt;&lt;P&gt;1 420000009D800C4400000002DF40&lt;/P&gt;&lt;P&gt;;&lt;/P&gt;&lt;P&gt;/* Now use an array to provide the ascii to ebcdic lookup values, and use the ebcdic values to build&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp; an ebcdic string.&amp;nbsp; In reality the array would be (2, 256), to cover all possible ascii values, but&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp; I have limited it here to only the ones in the ascii string.&amp;nbsp; I tested this code with the full ascii&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp; character set on a table with around 250,000 observations, and it took only a couple of seconds to&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp; execute. */&lt;/P&gt;&lt;P&gt;data accounts2;&lt;/P&gt;&lt;P&gt; set accounts;&lt;/P&gt;&lt;P&gt; length x $ 2;&lt;/P&gt;&lt;P&gt; length EBCDIC_VAL $ 512;&lt;/P&gt;&lt;P&gt; array ascii_ebcdic {2,9} $ &lt;/P&gt;&lt;P&gt;&amp;nbsp; ( &lt;/P&gt;&lt;P&gt;&amp;nbsp; '00' '02' '0C' '40' '42' '44' '80' '9D' 'DF'&lt;/P&gt;&lt;P&gt;&amp;nbsp; '00' '02' '0C' '7C' 'C2' 'C4' '20' '14' '59'&lt;/P&gt;&lt;P&gt;&amp;nbsp; );&lt;/P&gt;&lt;P&gt; do i = 1 to length(ascii_string)-1 by 2;&lt;/P&gt;&lt;P&gt;&amp;nbsp; x='';&lt;/P&gt;&lt;P&gt;&amp;nbsp; do j = 1 to 9; *this would be j = 1 to 256 in reality;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp; if substr(ascii_string,i,2) = trim(ascii_ebcdic(1,j)) then do;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; x = trim(ascii_ebcdic(2,j));&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp; end;&lt;/P&gt;&lt;P&gt;&amp;nbsp; end;&lt;/P&gt;&lt;P&gt;&amp;nbsp; EBCDIC_VAL = cats(EBCDIC_VAL,x);&lt;/P&gt;&lt;P&gt; end;&lt;/P&gt;&lt;P&gt; drop&amp;nbsp; ascii_ebcdic1-ascii_ebcdic512 x i j;&lt;/P&gt;&lt;P&gt;run;&lt;/P&gt;&lt;P&gt;*see the results;&lt;/P&gt;&lt;P&gt;proc print data = accounts2;&lt;/P&gt;&lt;P&gt;quit;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Now, this works perfectly, and seems to be fast.&amp;nbsp; This is all very new to me, so I am limited to trial and error.&amp;nbsp; My problem is that I do not want to have include the array statement and loops every time I want to convert between ascii and ebcdic in a data step, so I thought I would try a user defined function, like in VBA or SQL, then just call it when I need to convert between ascii and ebcdic.&amp;nbsp; I will post the code below, and I know it does not work, but I wanted you all to know where I am with this.&amp;nbsp; I sure would appreciate any tips, or links to documents that might describe a similar situation to this one.&amp;nbsp; Thank you for your time and help so far.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;/* I want the array to be a separate entity from the function, so it does not have to populate &lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp; with each call to the function.&amp;nbsp; When I run this I can see something is created in work.funcs,&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp; but I don't know how to determine what it is. */&lt;/P&gt;&lt;P&gt;proc fcmp outlib=work.funcs.ascii_ebcdic;&lt;/P&gt;&lt;P&gt;subroutine ascii_ebcdic ();&lt;/P&gt;&lt;P&gt; array ascii_ebcdic [2,9] $ ('00' '02' '0C' '40' '42' '44' '80' '9D' 'DF' &lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; '00' '02' '0C' '7C' 'C2' 'C4' '20' '14' '59');&lt;/P&gt;&lt;P&gt;endsub;&lt;/P&gt;&lt;P&gt;run;&lt;/P&gt;&lt;P&gt;/* I want this function to be able to reference the array ascii_ebcdic, but I keep getting an error,&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp; 'WARNING: Cannot find a library containing subroutine ASCII_EBCDIC'.&amp;nbsp; I don't know if this is &lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp; because my array was not created, or because my syntax is not correct.&amp;nbsp; I looked at several&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp; documents dealing with functions, but I could not find one specific to this need. */&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp; &lt;/P&gt;&lt;P&gt;proc fcmp outlib=work.funcs.ascii_ebcdic;&lt;/P&gt;&lt;P&gt;function AsciiToEbcdic(ascii_string) $; &lt;/P&gt;&lt;P&gt; length x $ 2;&lt;/P&gt;&lt;P&gt; length ebcdic_string $ 28;&lt;/P&gt;&lt;P&gt; do i = 1 to length(ascii_string)-1 by 2;&lt;/P&gt;&lt;P&gt;&amp;nbsp; x='';&lt;/P&gt;&lt;P&gt;&amp;nbsp; do j = 1 to 9;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp; if substr(ascii_string,i,2) = trim(ascii_ebcdic(1,j)) then do;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; x = trim(ascii_ebcdic(2,j));&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp; end;&lt;/P&gt;&lt;P&gt;&amp;nbsp; end;&lt;/P&gt;&lt;P&gt;&amp;nbsp; ebcdic_string = cats(ebcdic_string,x);&lt;/P&gt;&lt;P&gt; end;&lt;/P&gt;&lt;P&gt; return(ebcdic_string);&lt;/P&gt;&lt;P&gt;endsub;&lt;/P&gt;&lt;P&gt;run;&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Mon, 16 Apr 2012 14:07:25 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/Using-an-array-in-user-defined-function/m-p/85010#M24293</guid>
      <dc:creator>gsnidow</dc:creator>
      <dc:date>2012-04-16T14:07:25Z</dc:date>
    </item>
    <item>
      <title>Re: Using an array in user defined function</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/Using-an-array-in-user-defined-function/m-p/85011#M24294</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;What are you trying to do?&lt;/P&gt;&lt;P&gt;Why are you not just using built in SAS formats and informats like $HEX and $EBCDIC?&lt;/P&gt;&lt;P&gt;Why are you using an ARRAY instead of just a character variable?&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P style="font-family: 'Helvetica Neue', Helvetica, Arial, 'Lucida Grande', sans-serif; background-color: #ffffff;"&gt;&lt;SPAN style="font-family: 'courier new', courier;"&gt;do i = 1 to length(ascii_string)-1 by 2;&lt;/SPAN&gt;&lt;/P&gt;&lt;P style="font-family: 'Helvetica Neue', Helvetica, Arial, 'Lucida Grande', sans-serif; background-color: #ffffff;"&gt;&lt;SPAN style="font-family: 'courier new', courier;"&gt;&amp;nbsp; found=0;&lt;/SPAN&gt;&lt;/P&gt;&lt;P style="font-family: 'Helvetica Neue', Helvetica, Arial, 'Lucida Grande', sans-serif; background-color: #ffffff;"&gt;&lt;SPAN style="font-family: 'courier new', courier;"&gt;&amp;nbsp; do j = 1 to 18 by 2 while (not found);&lt;/SPAN&gt;&lt;/P&gt;&lt;P style="font-family: 'Helvetica Neue', Helvetica, Arial, 'Lucida Grande', sans-serif; background-color: #ffffff;"&gt;&lt;SPAN style="font-family: 'courier new', courier;"&gt;&amp;nbsp;&amp;nbsp; if substr(ascii_string,i,2) = substr(&lt;SPAN style="font-family: 'courier new', courier; background-color: #ffffff;"&gt;'00020C404244809DDF',j,2&lt;/SPAN&gt;) then found=j;&lt;/SPAN&gt;&lt;/P&gt;&lt;P style="font-family: 'Helvetica Neue', Helvetica, Arial, 'Lucida Grande', sans-serif; background-color: #ffffff;"&gt;&lt;SPAN style="font-family: 'courier new', courier;"&gt;&amp;nbsp; end;&lt;/SPAN&gt;&lt;/P&gt;&lt;P style="font-family: 'Helvetica Neue', Helvetica, Arial, 'Lucida Grande', sans-serif; background-color: #ffffff;"&gt;&lt;SPAN style="font-family: 'courier new', courier;"&gt;&amp;nbsp; if found then ebcdic_string = cats(ebcdic_string,substr(&lt;SPAN style="font-family: 'courier new', courier; background-color: #ffffff;"&gt;'00020C7CC2C4201459',found,2&lt;/SPAN&gt;));&lt;/SPAN&gt;&lt;/P&gt;&lt;P style="font-family: 'Helvetica Neue', Helvetica, Arial, 'Lucida Grande', sans-serif; background-color: #ffffff;"&gt;&lt;SPAN style="font-family: 'courier new', courier;"&gt;end;&lt;/SPAN&gt;&lt;/P&gt;&lt;P style="font-family: 'Helvetica Neue', Helvetica, Arial, 'Lucida Grande', sans-serif; background-color: #ffffff;"&gt;&lt;SPAN style="font-family: 'courier new', courier;"&gt;&lt;BR /&gt;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;Why not use other SAS functions like TRANWRD()?&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Mon, 16 Apr 2012 14:39:08 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/Using-an-array-in-user-defined-function/m-p/85011#M24294</guid>
      <dc:creator>Tom</dc:creator>
      <dc:date>2012-04-16T14:39:08Z</dc:date>
    </item>
    <item>
      <title>Re: Using an array in user defined function</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/Using-an-array-in-user-defined-function/m-p/85012#M24295</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Tom, thank you for your reply so quickly.&amp;nbsp; The problem I am having is that I am getting data from a DB2 database where the column is packed decimal.&amp;nbsp; To your point, and what I did not show is that I am using $HEX to get the column into a character string.&amp;nbsp; The issue is that since my machine has ascii as its native character set, the $HEX format produces an ascii string, where I need it to be an ebcdic string, as I would see when using the HEX() function in DB2 SQL.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;SAS is all new to me, as in I used it for the first time about 3 or 4 weeks ago, so I don't have a working knowledge of its functions and syntax.&amp;nbsp; At this point I am 100% trial and error, so when I get something to work, I don't know of a better way.&amp;nbsp; I do know that there probably is a better way, I just don't know how to get there. &lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Greg&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Mon, 16 Apr 2012 14:57:14 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/Using-an-array-in-user-defined-function/m-p/85012#M24295</guid>
      <dc:creator>gsnidow</dc:creator>
      <dc:date>2012-04-16T14:57:14Z</dc:date>
    </item>
    <item>
      <title>Re: Using an array in user defined function</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/Using-an-array-in-user-defined-function/m-p/85013#M24296</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Use the appropriate S370 format.&lt;/P&gt;&lt;P&gt;For example here is the S370FPD format.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-family: 'courier new', courier;"&gt;data test;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-family: 'courier new', courier;"&gt;&amp;nbsp; input x;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-family: 'courier new', courier;"&gt;&amp;nbsp; pd = put(x,s370fpd4.);&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-family: 'courier new', courier;"&gt;&amp;nbsp; y = input(pd,s370fpd4.);&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-family: 'courier new', courier;"&gt;&amp;nbsp; put x= pd=$hex8. +1 y=;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-family: 'courier new', courier;"&gt;cards;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-family: 'courier new', courier;"&gt;16&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-family: 'courier new', courier;"&gt;78&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-family: 'courier new', courier;"&gt;run;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-family: 'courier new', courier;"&gt;x=16 pd=0000016C&amp;nbsp; y=16&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-family: 'courier new', courier;"&gt;x=78 pd=0000078C&amp;nbsp; y=78&lt;/SPAN&gt;&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Mon, 16 Apr 2012 15:04:08 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/Using-an-array-in-user-defined-function/m-p/85013#M24296</guid>
      <dc:creator>Tom</dc:creator>
      <dc:date>2012-04-16T15:04:08Z</dc:date>
    </item>
    <item>
      <title>Re: Using an array in user defined function</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/Using-an-array-in-user-defined-function/m-p/85014#M24297</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Tom, I'll have to spend some time trying to understand what that is doing.&amp;nbsp; I can't see how I can use that to turn the ascii_string 4200000010900C4D0000000017F04E00000000F12A into the ebcdic_string C200000010300CD400000000268CD500000000495C.&amp;nbsp; For the ascii string here, I need to look at each set of 2 characters, stepping by 2 and get its corresponding ebcdic value.&amp;nbsp; For example, I need the code to start at position 1, and take '42' and look at the lookup array to return 'C2'.&amp;nbsp; Then it needs to go to position 3 of the ascii string, and take '00' and return the ebcdic value of '00', and append it to the previous 'C2', giving me 'C200'.&amp;nbsp; I need to repeat this look up process until every ascii value in the ascii string has been translated into ebcdic, giving me the final ebcdic string.&amp;nbsp; If there is a way to do this without using a lookup array, or permanent dataset for that matter, then I am just not seeing it so far.&amp;nbsp; Thanks. &lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Mon, 16 Apr 2012 15:49:22 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/Using-an-array-in-user-defined-function/m-p/85014#M24297</guid>
      <dc:creator>gsnidow</dc:creator>
      <dc:date>2012-04-16T15:49:22Z</dc:date>
    </item>
    <item>
      <title>Re: Using an array in user defined function</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/Using-an-array-in-user-defined-function/m-p/85015#M24298</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;If you had moved the file from the mainframe to your ASCII machine using Binary then you should be able to read the original values using the S370.... formats.&amp;nbsp; Did you move the file from the mainframe as ASCII instead binary and you are trying to undo the damage?&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;You need to know the location in the string of the Packed Decimal values you are trying to read.&lt;/P&gt;&lt;P&gt;How many numbers does the example 21 character string represent?&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Mon, 16 Apr 2012 16:10:55 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/Using-an-array-in-user-defined-function/m-p/85015#M24298</guid>
      <dc:creator>Tom</dc:creator>
      <dc:date>2012-04-16T16:10:55Z</dc:date>
    </item>
    <item>
      <title>Re: Using an array in user defined function</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/Using-an-array-in-user-defined-function/m-p/85016#M24299</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Why not just use the TRANSLATE function.&amp;nbsp; Convert your hex digits into actual characters that they represent and then translate them.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-family: 'courier new', courier;"&gt;data check;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-family: 'courier new', courier;"&gt;&amp;nbsp; from='00020C404244809DDF'x;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-family: 'courier new', courier;"&gt;&amp;nbsp; to&amp;nbsp; ='00020C7CC2C4201459'x;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-family: 'courier new', courier;"&gt;&amp;nbsp; input @1 asc $hex28. ;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-family: 'courier new', courier;"&gt;&amp;nbsp; ebc=translate(asc,to,from);&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-family: 'courier new', courier;"&gt;&amp;nbsp; format asc ebc $hex.;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-family: 'courier new', courier;"&gt;&amp;nbsp; put asc=/ebc=;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-family: 'courier new', courier;"&gt;cards;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-family: 'courier new', courier;"&gt;420000009D800C4400000002DF40&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-family: 'courier new', courier;"&gt;run;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-family: 'courier new', courier;"&gt;&lt;BR /&gt;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-family: 'courier new', courier;"&gt;asc=420000009D800C4400000002DF40&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-family: 'courier new', courier;"&gt;ebc=C200000014200CC400000002597C&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Note that the first three characters are the same in both the source and target translation strings.&amp;nbsp; So you could just remove those.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-family: 'courier new', courier;"&gt;&amp;nbsp; from='404244809DDF'x;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-family: 'courier new', courier;"&gt;&amp;nbsp; to&amp;nbsp; ='7CC2C4201459'x;&lt;/SPAN&gt;&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Mon, 16 Apr 2012 16:30:06 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/Using-an-array-in-user-defined-function/m-p/85016#M24299</guid>
      <dc:creator>Tom</dc:creator>
      <dc:date>2012-04-16T16:30:06Z</dc:date>
    </item>
    <item>
      <title>Re: Using an array in user defined function</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/Using-an-array-in-user-defined-function/m-p/85017#M24300</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;TRANSLATE looks very promissing, I'll try that out.&amp;nbsp; To answer your questions from your previous post, the packed decimal fields vary, and are actually an array of values.&amp;nbsp; In the example data above, each value is 14 characters long.&amp;nbsp; In some fields they are 38 characters long, it just depends on the field.&amp;nbsp; Another issue I am having, and it is probably due to my limited knowledge, the same field will vary in length across observations.&amp;nbsp; One observation might only have one value (14 characters), and the next observation might have 5 values (70 characters). &lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;I am creating a library reference using ODBC to the mainframe so I can query the DB2 tables directly.&amp;nbsp; We have a work around that uses a passthrough query in which we can use the DB2 HEX() function on the field to give the results we need.&amp;nbsp; The down side of this is that we can not join to any local table inside the passthrough querries.&amp;nbsp; By using $HEX512. (or whatever the length of the column is, it varies), I am able to turn the packed decimals into the ascii strings I have posted above.&amp;nbsp; I have searched long and hard for a format that would give me the ebcdic string that I need, but have come up blank.&amp;nbsp; I already created a SQL Server function that deals with the issue by converting the packed decimal to binary, then uses a lookup table as I have done in the array above.&amp;nbsp; I am guessing that since SAS is on my local machine, it assumes I want to see the ascii values, when in reality I need it to behave as if ebcdic was my native character set. &lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;I'll let you know if I have any luck with TRANSLATE.&amp;nbsp; Thank you so much for your help.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Greg&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Mon, 16 Apr 2012 16:38:35 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/Using-an-array-in-user-defined-function/m-p/85017#M24300</guid>
      <dc:creator>gsnidow</dc:creator>
      <dc:date>2012-04-16T16:38:35Z</dc:date>
    </item>
    <item>
      <title>Re: Using an array in user defined function</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/Using-an-array-in-user-defined-function/m-p/85018#M24301</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Perhaps you can post a few strings and the numbers that they represent?&lt;/P&gt;&lt;P&gt;How do you know how many numbers?&amp;nbsp; Is there a count variable somewhere else? Or is there a termination string? Or does the string just terminate?&amp;nbsp; If the latter then the LENGTH() function should let you calculate how many 14 character hex digits your string has.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Mon, 16 Apr 2012 17:02:39 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/Using-an-array-in-user-defined-function/m-p/85018#M24301</guid>
      <dc:creator>Tom</dc:creator>
      <dc:date>2012-04-16T17:02:39Z</dc:date>
    </item>
    <item>
      <title>Re: Using an array in user defined function</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/Using-an-array-in-user-defined-function/m-p/85019#M24302</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Here are 3 examples, all from the same DB2 field.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;TABLE border="0" cellpadding="0" cellspacing="0" style="WIDTH: 692px;"&gt;&lt;TBODY&gt;&lt;TR&gt;&lt;TD height="17" width="316"&gt;ASCII_STRING&lt;/TD&gt;&lt;TD width="376"&gt;EBCDIC_STRING&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD height="17"&gt;4A000000000029&lt;/TD&gt;&lt;TD&gt;D100000000005D&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD height="17"&gt;490000008798F04A0000000082F0&lt;/TD&gt;&lt;TD&gt;C900000017388CD100000000228C&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD height="17"&gt;4200000019D8F0430000007FF80C4400000001DF14&lt;/TD&gt;&lt;TD&gt;C200000019808CC300000007700CC400000001593C&lt;/TD&gt;&lt;/TR&gt;&lt;/TBODY&gt;&lt;/TABLE&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;The the ascii_string variable comes from using $HEX. on the DB2 column, the ebcdic_string column is what I produced with my array.&amp;nbsp; Lets look at the ebcdic strings one by one, since those are what I need.&lt;/P&gt;&lt;P&gt;1) D100000000005D&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; Characters 3-13 represent a number, and I need to dived by 100 to put the decimal back.&amp;nbsp; In this case, the number would be 0.05 after stripping off the leading zeros.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; If the first two characters are in ('C3','C7','C8','','C9','D1','D2','D3'), then the entire value in 3-13 gets multiplied by 0, else 1.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; If the last character is in ('B', 'D') then the number is negative, else it is positive.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; So, for this one, the only thing that matters is the initial 'D1', since it renders the value to 0.00, and the rest is moot.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;2) C900000017388CD100000000228C&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; This one has two values, C900000017388C and D100000000228C.&amp;nbsp; In both cases, the leading 2 characters of 'C9' and 'D1' render it 0.00, so again the rest is moot.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;3) C200000019808CC300000007700CC400000001593C&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; This one has three values C200000019808C, C300000007700C, and C400000001593C. &lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; The first value, having characters 1-2 = 'C2' renders it a non-zero value, so the absolute value becomes 77.00, and since the last character is not in ('B','D'), it has a positive value.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; The second value, having characters 1-2 = 'C3' renders it 0.00, so the rest of it is moot.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; The third value, having characters 1-2 = 'C4', renders it a non-zero absolute value of 15.93, and the last character of 'C' makes it a possitive value.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; So, for this one, having three values, I end up with a positive +77.00, 0.00, and +15.93, which are to be summed, so the total value of the one ebcdic string is 92.93.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;I know it may seem convoluted, but that is the data, so I have to deal with it.&amp;nbsp; A little SQL and a numbers table make light work of dicing it up.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;And to your point, If the mainframe field is packed decimal with a length of 78, then I know I need to double that for my ebcdic string.&amp;nbsp; So I do use the length function to determine how long it needs to be. &lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Greg&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Mon, 16 Apr 2012 17:32:37 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/Using-an-array-in-user-defined-function/m-p/85019#M24302</guid>
      <dc:creator>gsnidow</dc:creator>
      <dc:date>2012-04-16T17:32:37Z</dc:date>
    </item>
    <item>
      <title>Re: Using an array in user defined function</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/Using-an-array-in-user-defined-function/m-p/85020#M24303</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Greg,&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Try reviewing this usage note on packed decimal fields in DB2: &lt;A href="http://support.sas.com/kb/32/742.html"&gt;http://support.sas.com/kb/32/742.html&lt;/A&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;I would not recommend using the hex() function in DB2 since, as you are aware, SAS will obfuscate the information.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Mon, 16 Apr 2012 18:35:58 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/Using-an-array-in-user-defined-function/m-p/85020#M24303</guid>
      <dc:creator>FriedEgg</dc:creator>
      <dc:date>2012-04-16T18:35:58Z</dc:date>
    </item>
    <item>
      <title>Re: Using an array in user defined function</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/Using-an-array-in-user-defined-function/m-p/85021#M24304</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Looks to me like using the $EBCDIC format to convert your values from ASCII to EBCDIC then lets you use the S370FPD6.2 informat on the last 6 characters of each 7 character string.&amp;nbsp; But your example seems to have reversed which of the first two values in the row with three values should be considered as zero.&amp;nbsp; So the total sum is different.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-family: 'courier new', courier;"&gt;data check;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-family: 'courier new', courier;"&gt;&amp;nbsp; input hex $70.;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-family: 'courier new', courier;"&gt;&amp;nbsp; length ascii ebcdic $7 first $2 value total 8;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-family: 'courier new', courier;"&gt;&amp;nbsp; put / _n_=;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-family: 'courier new', courier;"&gt;&amp;nbsp; total=0;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-family: 'courier new', courier;"&gt;&amp;nbsp; do i=0 to ceil(length(hex)/14) -1 ;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-family: 'courier new', courier;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; ascii = input(substr(hex,1+i*14,14),$hex14.);&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-family: 'courier new', courier;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; ebcdic=put(ascii,$ebcdic7.);&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-family: 'courier new', courier;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; first= put(ebcdic,$hex2.);&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-family: 'courier new', courier;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; value = input(substr(ebcdic,2),s370fpd6.2);&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-family: 'courier new', courier;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; put i= first= value= @;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-family: 'courier new', courier;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; if first in ('C3','C7','C8','','C9','D1','D2','D3')&amp;nbsp; then do;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-family: 'courier new', courier;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; value=0; put '-&amp;gt; ' value @;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-family: 'courier new', courier;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; end;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-family: 'courier new', courier;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; total=sum(total,value);&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-family: 'courier new', courier;"&gt;&amp;nbsp; end;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-family: 'courier new', courier;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; put / total=;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-family: 'courier new', courier;"&gt;cards;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-family: 'courier new', courier;"&gt;4A000000000029&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-family: 'courier new', courier;"&gt;490000008798F04A0000000082F0&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-family: 'courier new', courier;"&gt;4200000019D8F0430000007FF80C4400000001DF14&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-family: 'courier new', courier;"&gt;run;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-family: 'courier new', courier;"&gt;&lt;BR /&gt;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;_N_=1&lt;/P&gt;&lt;P&gt;i=0 first=D1 value=-0.05 -&amp;gt; 0&lt;/P&gt;&lt;P&gt;total=0&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;_N_=2&lt;/P&gt;&lt;P&gt;i=0 first=C9 value=173.88 -&amp;gt; 0 i=1 first=D1 value=2.28 -&amp;gt; 0&lt;/P&gt;&lt;P&gt;total=0&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;_N_=3&lt;/P&gt;&lt;P&gt;i=0 first=C2 value=198.08 i=1 first=C3 value=77 -&amp;gt; 0 i=2 first=C4 value=15.93&lt;/P&gt;&lt;P&gt;total=214.01&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Mon, 16 Apr 2012 20:35:44 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/Using-an-array-in-user-defined-function/m-p/85021#M24304</guid>
      <dc:creator>Tom</dc:creator>
      <dc:date>2012-04-16T20:35:44Z</dc:date>
    </item>
    <item>
      <title>Re: Using an array in user defined function</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/Using-an-array-in-user-defined-function/m-p/85022#M24305</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Maybe you can use TRANTAB Procedure +&lt;/P&gt;&lt;P&gt;performing transport-format translations when you transfer files with the CPORT&lt;/P&gt;&lt;P&gt;and CIMPORT procedures&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;to translate character from EBCDIC to ASCII&amp;nbsp; .&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Ksharp&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Tue, 17 Apr 2012 02:56:09 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/Using-an-array-in-user-defined-function/m-p/85022#M24305</guid>
      <dc:creator>Ksharp</dc:creator>
      <dc:date>2012-04-17T02:56:09Z</dc:date>
    </item>
    <item>
      <title>Re: Using an array in user defined function</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/Using-an-array-in-user-defined-function/m-p/85023#M24306</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Tom&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; Thank you so much for taking your time to consider my issue as you have done here.&amp;nbsp; I'm not sure why the difference, but it could be a translation error on my part.&amp;nbsp; Anyhow, after reading your solution, I spent some time reading about formats last night, and was a bit overwhelmed at how many there are.&amp;nbsp; I knew there were more than just char and number, but I had no idea how vast the universe was.&amp;nbsp; Anyhow, I'll have to take some time do digest it all, so I will post back when I fully understand your code.&amp;nbsp; Thanks again.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Greg&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Tue, 17 Apr 2012 10:38:11 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/Using-an-array-in-user-defined-function/m-p/85023#M24306</guid>
      <dc:creator>gsnidow</dc:creator>
      <dc:date>2012-04-17T10:38:11Z</dc:date>
    </item>
    <item>
      <title>Re: Using an array in user defined function</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/Using-an-array-in-user-defined-function/m-p/85024#M24307</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Thank you for pointing that out FriedEgg.&amp;nbsp; As Tom's post indicates, we may have an issue of which we were unaware.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Greg&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Tue, 17 Apr 2012 10:39:56 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/Using-an-array-in-user-defined-function/m-p/85024#M24307</guid>
      <dc:creator>gsnidow</dc:creator>
      <dc:date>2012-04-17T10:39:56Z</dc:date>
    </item>
    <item>
      <title>Re: Using an array in user defined function</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/Using-an-array-in-user-defined-function/m-p/85025#M24308</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Tom, if you are still willing, I seem to be doing something wrong.&amp;nbsp; I am trying to use formats to convert the ascii string as you have done, and I am having issues.&amp;nbsp; Sometimes the format works, and sometimes it does not.&amp;nbsp; If you would be so kind to look at the below and see if anything stands out to you.&amp;nbsp; Also, please bear with me with respect to the array, since I know it produces correct values, I have included it as a sanity check.&amp;nbsp; Below are two examples, on the first of which the format works, and the second of which the format does not work.&amp;nbsp; In both cases the variable ebcdic_by_array produces the correct values.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;data test;&lt;/P&gt;&lt;P&gt; input ascii_string $14.;&lt;/P&gt;&lt;P&gt; length x $ 2;&lt;/P&gt;&lt;P&gt; length ebcdic_by_array $ 14;&lt;/P&gt;&lt;P&gt; array ascii_ebcdic {2,8} $ &lt;/P&gt;&lt;P&gt;&amp;nbsp; ( &lt;/P&gt;&lt;P&gt;&amp;nbsp; '00' '09' '1C' '26' '49' '98' 'CD' 'E6'&lt;/P&gt;&lt;P&gt;&amp;nbsp; '00' '05' '1C' '50' 'C9' '38' '75' '9C'&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; );&lt;/P&gt;&lt;P&gt; do i = 1 to length(ascii_string)-1 by 2;&lt;/P&gt;&lt;P&gt;&amp;nbsp; x='';&lt;/P&gt;&lt;P&gt;&amp;nbsp; do j = 1 to 8;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp; if substr(ascii_string,i,2) = trim(ascii_ebcdic(1,j)) then do;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; x = trim(ascii_ebcdic(2,j));&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp; end;&lt;/P&gt;&lt;P&gt;&amp;nbsp; end;&lt;/P&gt;&lt;P&gt;&amp;nbsp; ebcdic_by_array = cats(ebcdic_by_array,x);&lt;/P&gt;&lt;P&gt; end;&lt;/P&gt;&lt;P&gt; ascii = input(ascii_string,$hex14.);&lt;/P&gt;&lt;P&gt; ebcdic = put(ascii,$ebcdic7.);&lt;/P&gt;&lt;P&gt; ebcdic_by_format = put(ebcdic,$hex14.);&lt;/P&gt;&lt;P&gt; drop&amp;nbsp; ascii_ebcdic1-ascii_ebcdic512 x i j;&lt;/P&gt;&lt;P&gt;cards;&lt;/P&gt;&lt;P&gt;4900000009CD1C&lt;/P&gt;&lt;P&gt;490000009826E6&lt;/P&gt;&lt;P&gt;run;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Greg&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Tue, 17 Apr 2012 15:20:34 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/Using-an-array-in-user-defined-function/m-p/85025#M24308</guid>
      <dc:creator>gsnidow</dc:creator>
      <dc:date>2012-04-17T15:20:34Z</dc:date>
    </item>
    <item>
      <title>Re: Using an array in user defined function</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/Using-an-array-in-user-defined-function/m-p/85026#M24309</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;I am not sure how your loop can work to convert all possible 2 character HEX strings from ASCII to EBCDIC codes.&amp;nbsp; You are only attempting to convert 8 characters out of the 256 combinations possible with 8 bits.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Tue, 17 Apr 2012 19:57:58 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/Using-an-array-in-user-defined-function/m-p/85026#M24309</guid>
      <dc:creator>Tom</dc:creator>
      <dc:date>2012-04-17T19:57:58Z</dc:date>
    </item>
    <item>
      <title>Re: Using an array in user defined function</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/Using-an-array-in-user-defined-function/m-p/85027#M24310</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Indeed you are correct.&amp;nbsp; I only included the values necessary to convert the two strings I used as examples, and I should have stated as such.&amp;nbsp; If I included all 256 possible values they would have become a jumbled mess here.&amp;nbsp; In my code I do have the whole character set, and that is what I used to test my million rows.&amp;nbsp; If there is a way to attach files here I will certainly attach it if you would be interested.&amp;nbsp; Thank you.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Tue, 17 Apr 2012 20:15:23 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/Using-an-array-in-user-defined-function/m-p/85027#M24310</guid>
      <dc:creator>gsnidow</dc:creator>
      <dc:date>2012-04-17T20:15:23Z</dc:date>
    </item>
    <item>
      <title>Re: Using an array in user defined function</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/Using-an-array-in-user-defined-function/m-p/85028#M24311</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Here you go.&amp;nbsp; I copied it from my program editor into here, then copied it from here back to the editor to make sure it kept it's format, and it worked.&amp;nbsp; Thanks. &lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;array ascii_ebcdic {2,256} $ &lt;/P&gt;&lt;P&gt;&amp;nbsp; ( &lt;/P&gt;&lt;P&gt;&amp;nbsp; '00' '01' '02' '03' '04' '05' '06' '07' '08' '09' '0A' '0B' '0C' '0D' '0E' '0F' '10' '11' '12' '13' '14' '15' '16' '17' '18' '19' '1A' '1B' '1C' '1D' '1E' '1F' '20' '21' '22' '23' '24' '25' '26' '27' '28' '29' '2A' '2B' '2C' '2D' '2E' '2F' '30' '31' '32' '33' '34' '35' '36' '37' '38' '39' '3A' '3B' '3C' '3D' '3E' '3F' '40' '41' '42' '43' '44' '45' '46' '47' '48' '49' '4A' '4B' '4C' '4D' '4E' '4F' '50' '51' '52' '53' '54' '55' '56' '57' '58' '59' '5A' '5B' '5C' '5D' '5E' '5F' '60' '61' '62' '63' '64' '65' '66' '67' '68' '69' '6A' '6B' '6C' '6D' '6E' '6F' '70' '71' '72' '73' '74' '75' '76' '77' '78' '79' '7A' '7B' '7C' '7D' '7E' '7F' '80' '81' '82' '83' '84' '85' '86' '87' '88' '89' '8A' '8B' '8C' '8D' '8E' '8F' '90' '91' '92' '93' '94' '95' '96' '97' '98' '99' '9A' '9B' '9C' '9D' '9E' '9F' 'A0' 'A1' 'A2' 'A3' 'A4' 'A5' 'A6' 'A7' 'A8' 'A9' 'AA' 'AB' 'AC' 'AD' 'AE' 'AF' 'B0' 'B1' 'B2' 'B3' 'B4' 'B5' 'B6' 'B7' 'B8' 'B9' 'BA' 'BB' 'BC' 'BD' 'BE' 'BF' 'C0' 'C1' 'C2' 'C3' 'C4' 'C5' 'C6' 'C7' 'C8' 'C9' 'CA' 'CB' 'CC' 'CD' 'CE' 'CF' 'D0' 'D1' 'D2' 'D3' 'D4' 'D5' 'D6' 'D7' 'D8' 'D9' 'DA' 'DB' 'DC' 'DD' 'DE' 'DF' 'E0' 'E1' 'E2' 'E3' 'E4' 'E5' 'E6' 'E7' 'E8' 'E9' 'EA' 'EB' 'EC' 'ED' 'EE' 'EF' 'F0' 'F1' 'F2' 'F3' 'F4' 'F5' 'F6' 'F7' 'F8' 'F9' 'FA' 'FB' 'FC' 'FD' 'FE' 'FF'&lt;/P&gt;&lt;P&gt;&amp;nbsp; '00' '01' '02' '03' '37' '2D' '2E' '2F' '16' '05' '25' '0B' '0C' '0D' '0E' '0F' '10' '11' '12' '13' '3C' '3D' '32' '26' '18' '19' '3F' '27' '1C' '1D' '1E' '1F' '40' '5A' '7F' '7B' '5B' '6C' '50' '7D' '4D' '5D' '5C' '4E' '6B' '60' '4B' '61' 'F0' 'F1' 'F2' 'F3' 'F4' 'F5' 'F6' 'F7' 'F8' 'F9' '7A' '5E' '4C' '7E' '6E' '6F' '7C' 'C1' 'C2' 'C3' 'C4' 'C5' 'C6' 'C7' 'C8' 'C9' 'D1' 'D2' 'D3' 'D4' 'D5' 'D6' 'D7' 'D8' 'D9' 'E2' 'E3' 'E4' 'E5' 'E6' 'E7' 'E8' 'E9' 'BA' 'E0' 'BB' 'B0' '6D' '79' '81' '82' '83' '84' '85' '86' '87' '88' '89' '91' '92' '93' '94' '95' '96' '97' '98' '99' 'A2' 'A3' 'A4' 'A5' 'A6' 'A7' 'A8' 'A9' 'C0' '4F' 'D0' 'A1' '07' '20' '21' '22' '23' '24' '15' '06' '17' '28' '29' '2A' '2B' '2C' '09' '0A' '1B' '30' '31' '1A' '33' '34' '35' '36' '08' '38' '39' '3A' '3B' '04' '14' '3E' 'FF' '41' 'AA' '4A' 'B1' '9F' 'B2' '6A' 'B5' 'BD' 'B4' '9A' '8A' '5F' 'CA' 'AF' 'BC' '90' '8F' 'EA' 'FA' 'BE' 'A0' 'B6' 'B3' '9D' 'DA' '9B' '8B' 'B7' 'B8' 'B9' 'AB' '64' '65' '62' '66' '63' '67' '9E' '68' '74' '71' '72' '73' '78' '75' '76' '77' 'AC' '69' 'ED' 'EE' 'EB' 'EF' 'EC' 'BF' '80' 'FD' 'FE' 'FB' 'FC' 'AD' 'AE' '59' '44' '45' '42' '46' '43' '47' '9C' '48' '54' '51' '52' '53' '58' '55' '56' '57' '8C' '49' 'CD' 'CE' 'CB' 'CF' 'CC' 'E1' '70' 'DD' 'DE' 'DB' 'DC' '8D' '8E' 'DF'&lt;/P&gt;&lt;P&gt;&amp;nbsp; );&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Tue, 17 Apr 2012 20:21:19 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/Using-an-array-in-user-defined-function/m-p/85028#M24311</guid>
      <dc:creator>gsnidow</dc:creator>
      <dc:date>2012-04-17T20:21:19Z</dc:date>
    </item>
    <item>
      <title>Re: Using an array in user defined function</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/Using-an-array-in-user-defined-function/m-p/85029#M24312</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Do you want to attach file? if so you can click the "Use advanced editor " on the top right corner.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Tue, 17 Apr 2012 21:00:37 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/Using-an-array-in-user-defined-function/m-p/85029#M24312</guid>
      <dc:creator>Linlin</dc:creator>
      <dc:date>2012-04-17T21:00:37Z</dc:date>
    </item>
  </channel>
</rss>

