<?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: Arryas, Loops and Datasets...efficiency question in SAS Procedures</title>
    <link>https://communities.sas.com/t5/SAS-Procedures/Arryas-Loops-and-Datasets-efficiency-question/m-p/114095#M31561</link>
    <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;I forgot to mention I am using EG 4.3 so I don't think Hash Tables are an option.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Astounding thank you, that sounds like a great method.&amp;nbsp; I am doing something wrong though. The code runs fine but it doesn't delete any observations on my test set (where it should delete 80). I really haven't used formats much. What am I doing wrong? &lt;/P&gt;&lt;P&gt;data delete_list;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; infile "myTextFile"&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; input start $;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; retain fmtname "$form label "delete me";&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; run;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;* I get a 3 column dataset with the same number of observations and my codes in the first column, $form in the second, and delete me in the third);&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;proc format cntlin=delete_list;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;data IGIV2_filtered (drop=i);&lt;/P&gt;&lt;P&gt;set IGIV1_all;&lt;/P&gt;&lt;P&gt;array Diag{12} diag1-diag12;&lt;/P&gt;&lt;P&gt;do i = 1 to 12;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; if put(diagCode{i}, $form.) = "delete me" then delete;&lt;/P&gt;&lt;P&gt;end;&lt;/P&gt;&lt;P&gt;run;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;What am I doing wrong?&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Thanks again!&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
    <pubDate>Wed, 16 May 2012 15:16:37 GMT</pubDate>
    <dc:creator>Rewena</dc:creator>
    <dc:date>2012-05-16T15:16:37Z</dc:date>
    <item>
      <title>Arryas, Loops and Datasets...efficiency question</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/Arryas-Loops-and-Datasets-efficiency-question/m-p/114091#M31557</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hello! I'm new here and need some help.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;I have a huge data set which I have to search for codes. The codes can appear in any of multiple columns. The codes are alphanumberic.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Normally I use code like this:&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;data file1 (drop=i);&lt;/P&gt;&lt;P&gt;set file2;&lt;/P&gt;&lt;P&gt;array&amp;nbsp; field{25} field1-field25;&lt;/P&gt;&lt;P&gt;do i = 1 to 25;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; if (field{i} = "20" or field{i} = "25") then do;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; delete;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; leave;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; end;&lt;/P&gt;&lt;P&gt;end;&lt;/P&gt;&lt;P&gt;run;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;This seems to work fine. However now instead of just 1 or 2 codes to search by I am given lists of 500 to 3800 codes. So my question is... is how is the best way to accomplish this. I have the codes in a sorted one column text file.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Thank you!&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Mon, 14 May 2012 15:53:31 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/Arryas-Loops-and-Datasets-efficiency-question/m-p/114091#M31557</guid>
      <dc:creator>Rewena</dc:creator>
      <dc:date>2012-05-14T15:53:31Z</dc:date>
    </item>
    <item>
      <title>Re: Arryas, Loops and Datasets...efficiency question</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/Arryas-Loops-and-Datasets-efficiency-question/m-p/114092#M31558</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Rewena,&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;The easiest way would be to turn the one-column file into a format.&amp;nbsp; It would be the equivalent of:&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;proc format;&lt;/P&gt;&lt;P&gt;value $fields "20" = "delete me"&amp;nbsp; "25" = "delete me";&lt;/P&gt;&lt;P&gt;run;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Here's one way to do that:&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;data delete_list;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp; infile one_col;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp; input start $;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp; retain fmtname "$fields" label "delete me";&lt;/P&gt;&lt;P&gt;run;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;proc format cntlin=delete_list;&lt;/P&gt;&lt;P&gt;run;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;That would create the format.&amp;nbsp; Then to use it, change the interior of the DO loop:&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;if put(field{i}, $fields.) = "delete me" then delete;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Once you delete a record, you don't have to worry about a LEAVE statement.&amp;nbsp; You're already out of the DO group.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Good luck.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Mon, 14 May 2012 17:42:24 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/Arryas-Loops-and-Datasets-efficiency-question/m-p/114092#M31558</guid>
      <dc:creator>Astounding</dc:creator>
      <dc:date>2012-05-14T17:42:24Z</dc:date>
    </item>
    <item>
      <title>Re: Arryas, Loops and Datasets...efficiency question</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/Arryas-Loops-and-Datasets-efficiency-question/m-p/114093#M31559</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Here is one approach:&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;data Amaster;&lt;/P&gt;&lt;P&gt;&amp;nbsp; informat code $2.;&lt;/P&gt;&lt;P&gt;&amp;nbsp; input code;&lt;/P&gt;&lt;P&gt;&amp;nbsp; cards;&lt;/P&gt;&lt;P&gt;25&lt;/P&gt;&lt;P&gt;14&lt;/P&gt;&lt;P&gt;BB&lt;/P&gt;&lt;P&gt;;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;data _null_;&lt;/P&gt;&lt;P&gt; if 0 then set Amaster nobs=nobs;&lt;/P&gt;&lt;P&gt; CALL SYMPUT('NUMREC',nobs);&lt;/P&gt;&lt;P&gt; stop;&lt;/P&gt;&lt;P&gt;run;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;data have;&lt;/P&gt;&lt;P&gt;&amp;nbsp; informat field1-field5 $2.;&lt;/P&gt;&lt;P&gt;&amp;nbsp; input id field1-field5;&lt;/P&gt;&lt;P&gt;&amp;nbsp; cards;&lt;/P&gt;&lt;P&gt;1 AA FF 11 12 CC&lt;/P&gt;&lt;P&gt;2 DD 25 14 XX YY&lt;/P&gt;&lt;P&gt;3 DD EE FF 25 CC&lt;/P&gt;&lt;P&gt;4 AA BB DD DD EE&lt;/P&gt;&lt;P&gt;;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;data want (drop=codes: x i);&lt;/P&gt;&lt;P&gt;&amp;nbsp; array codes(&amp;amp;numrec.) $2.;&lt;/P&gt;&lt;P&gt;&amp;nbsp; i=0;&lt;/P&gt;&lt;P&gt;&amp;nbsp; do until (eof1);&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; set Amaster end=eof1;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; i=i+1;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; codes(i)=code;&lt;/P&gt;&lt;P&gt;&amp;nbsp; end;&lt;/P&gt;&lt;P&gt;&amp;nbsp; do until (eof2);&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; array fields(*) $2. field1-field5;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; set have end=eof2;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; do i=1 to dim(fields);&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; if fields(i) in codes then do;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; x=1;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; leave;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; end;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; end;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; if missing(x) then output;&lt;/P&gt;&lt;P&gt;&amp;nbsp; end;&lt;/P&gt;&lt;P&gt;run;&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Mon, 14 May 2012 18:03:58 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/Arryas-Loops-and-Datasets-efficiency-question/m-p/114093#M31559</guid>
      <dc:creator>art297</dc:creator>
      <dc:date>2012-05-14T18:03:58Z</dc:date>
    </item>
    <item>
      <title>Re: Arryas, Loops and Datasets...efficiency question</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/Arryas-Loops-and-Datasets-efficiency-question/m-p/114094#M31560</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;I prefer to Hash Table .&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Tue, 15 May 2012 02:42:04 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/Arryas-Loops-and-Datasets-efficiency-question/m-p/114094#M31560</guid>
      <dc:creator>Ksharp</dc:creator>
      <dc:date>2012-05-15T02:42:04Z</dc:date>
    </item>
    <item>
      <title>Re: Arryas, Loops and Datasets...efficiency question</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/Arryas-Loops-and-Datasets-efficiency-question/m-p/114095#M31561</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;I forgot to mention I am using EG 4.3 so I don't think Hash Tables are an option.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Astounding thank you, that sounds like a great method.&amp;nbsp; I am doing something wrong though. The code runs fine but it doesn't delete any observations on my test set (where it should delete 80). I really haven't used formats much. What am I doing wrong? &lt;/P&gt;&lt;P&gt;data delete_list;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; infile "myTextFile"&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; input start $;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; retain fmtname "$form label "delete me";&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; run;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;* I get a 3 column dataset with the same number of observations and my codes in the first column, $form in the second, and delete me in the third);&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;proc format cntlin=delete_list;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;data IGIV2_filtered (drop=i);&lt;/P&gt;&lt;P&gt;set IGIV1_all;&lt;/P&gt;&lt;P&gt;array Diag{12} diag1-diag12;&lt;/P&gt;&lt;P&gt;do i = 1 to 12;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; if put(diagCode{i}, $form.) = "delete me" then delete;&lt;/P&gt;&lt;P&gt;end;&lt;/P&gt;&lt;P&gt;run;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;What am I doing wrong?&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Thanks again!&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Wed, 16 May 2012 15:16:37 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/Arryas-Loops-and-Datasets-efficiency-question/m-p/114095#M31561</guid>
      <dc:creator>Rewena</dc:creator>
      <dc:date>2012-05-16T15:16:37Z</dc:date>
    </item>
    <item>
      <title>Re: Arryas, Loops and Datasets...efficiency question</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/Arryas-Loops-and-Datasets-efficiency-question/m-p/114096#M31562</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Rewena,&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Mostly, it looks like everything is fine and should work.&amp;nbsp; Let's explore a few things though.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;The first DATA step looks like it contains a few syntax errors (missing semicolon, unbalanced quotes).&amp;nbsp; But you describe the output properly, so I assume that you ran the right program, and that the code you posted is slightly different than what you actually ran.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;The last DATA step uses Diag as the array name, but later refers to the array as diagCode.&amp;nbsp; If you actually ran it this way, you would have gotten an error message.&amp;nbsp; So again I believe that the program you ran was slightly different than the program you posted.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;My best guess as to what is happening is that the diagnostic codes in the data do not actually match the codes in the delete list.&amp;nbsp; Do the codes in IGIV1_all contain leading blanks?&amp;nbsp; Could they have been entered through a data entry system that appends a carriage return at the end?&amp;nbsp; You will have to do a little digging on this.&amp;nbsp; Find one of the 80 that should have been deleted, and explore what is actually in the data.&amp;nbsp; If one particular observation has diag5 that should be deleted, try this.&amp;nbsp; If diag5 has a length of 8:&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;length newvar $ 16;&lt;/P&gt;&lt;P&gt;newvar = put(diag5, $hex16.);&lt;/P&gt;&lt;P&gt;put diag5= newvar=;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Let's find out what's actually in the data and that should point to a solution.&amp;nbsp; It could be that the problem is with the delete list codes, rather than the data itself.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Good luck.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Wed, 16 May 2012 15:36:39 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/Arryas-Loops-and-Datasets-efficiency-question/m-p/114096#M31562</guid>
      <dc:creator>Astounding</dc:creator>
      <dc:date>2012-05-16T15:36:39Z</dc:date>
    </item>
    <item>
      <title>Re: Arryas, Loops and Datasets...efficiency question</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/Arryas-Loops-and-Datasets-efficiency-question/m-p/114097#M31563</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Output:&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Diag5&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; newvar&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/P&gt;&lt;P&gt;27903&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; 3237393033&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Thanks!&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Wed, 16 May 2012 16:08:58 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/Arryas-Loops-and-Datasets-efficiency-question/m-p/114097#M31563</guid>
      <dc:creator>Rewena</dc:creator>
      <dc:date>2012-05-16T16:08:58Z</dc:date>
    </item>
    <item>
      <title>Re: Arryas, Loops and Datasets...efficiency question</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/Arryas-Loops-and-Datasets-efficiency-question/m-p/114098#M31564</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Rewena,&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;So far so good.&amp;nbsp; Can I assume that DIAG5 is defined as having a length of 5 when you run a PROC CONTENTS?&amp;nbsp; If not, adjust NEWVAR to be twice the length of DIAG5, and retest.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Just to rule out a few possibilities, let's try these steps as well.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Check the spelling.&amp;nbsp; Make sure "delete me" is spelled the same way, with the same capitalization throughout.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Check when START is "27903" in the DELETE_LIST data set.&amp;nbsp; Run the same test, but use the longer length ($ 16) for NEWVAR.&amp;nbsp; The statement INPUT START $ ; will assign START a length of 8.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Finally, I don't think this will be the fix but try changing the format in the PUT function:&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;put(diagCode{i}, $form9.)&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;That will make sure that the PUT function returns 9 characters, enough to spell out all the characters in "delete me".&amp;nbsp; (Do NOT change the value of FMTNAME in the prior step.)&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Wed, 16 May 2012 16:23:29 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/Arryas-Loops-and-Datasets-efficiency-question/m-p/114098#M31564</guid>
      <dc:creator>Astounding</dc:creator>
      <dc:date>2012-05-16T16:23:29Z</dc:date>
    </item>
    <item>
      <title>Re: Arryas, Loops and Datasets...efficiency question</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/Arryas-Loops-and-Datasets-efficiency-question/m-p/114099#M31565</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Include for testing purposes two elements:&lt;/P&gt;&lt;P&gt;1. in the creation of the format include an "other" value, e.g.:&lt;/P&gt;&lt;P&gt;HLO = 'O'; * to specify that it is "other";&lt;/P&gt;&lt;P&gt;Label = '!!$$##'; * or anything else, as long as you can distinguish it from the "real" label;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;2. Include a PUTLOG in the DO-loop where you are testing whether to delete:&lt;/P&gt;&lt;P&gt;PUTLOG diagCode{i}= $form.; * now you can see whether it falls into "other" or one of the delete-values;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;That would give you a clue whether there is something wrong with the comparison with "delete me" or with the value in diagCode{i}.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Thu, 14 Nov 2013 23:20:16 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/Arryas-Loops-and-Datasets-efficiency-question/m-p/114099#M31565</guid>
      <dc:creator>ErikT</dc:creator>
      <dc:date>2013-11-14T23:20:16Z</dc:date>
    </item>
    <item>
      <title>Re: Arryas, Loops and Datasets...efficiency question</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/Arryas-Loops-and-Datasets-efficiency-question/m-p/114100#M31566</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hash tables are production since SAS 9.1.3 (I believe) so this should work for you.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;data have;&lt;BR /&gt;&amp;nbsp; informat field1-field5 $2.;&lt;BR /&gt;&amp;nbsp; input id field1-field5;&lt;BR /&gt;&amp;nbsp; cards;&lt;BR /&gt;1 AA FF 11 12 CC&lt;BR /&gt;2 DD 25 14 XX YY&lt;BR /&gt;3 DD EE FF 25 CC&lt;BR /&gt;4 AA BB DD DD EE&lt;BR /&gt;;&lt;BR /&gt;run;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;data exclusion_list;&lt;BR /&gt;&amp;nbsp; input _excl_code :$2.;&lt;BR /&gt;&amp;nbsp; datalines;&lt;BR /&gt;AA&lt;BR /&gt;BB&lt;BR /&gt;;&lt;BR /&gt;run;&lt;/P&gt;&lt;P&gt;&lt;BR /&gt;data want (drop=_:);&lt;BR /&gt;&amp;nbsp; set have;&lt;BR /&gt;&amp;nbsp; array&amp;nbsp; field{*} field1-field5;&lt;BR /&gt;&amp;nbsp; if _n_=1 then &lt;BR /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; do;&lt;BR /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; if 0 then set exclusion_list(keep=_excl_code);&lt;BR /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; declare hash h (dataset:'exclusion_list',hashexp:5);&lt;BR /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; _rc=h.defineKey('_excl_code');&lt;BR /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; _rc=h.defineDone();&lt;BR /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; end;&lt;/P&gt;&lt;P&gt;&amp;nbsp; do _i = 1 to dim(field);&lt;BR /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; if h.check(key:field[_i]) = 0 then&lt;BR /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; do;&lt;BR /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; delete;&lt;BR /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; leave;&lt;BR /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; end;&lt;BR /&gt;&amp;nbsp; end;&lt;BR /&gt;run;&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Thu, 14 Nov 2013 23:50:06 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/Arryas-Loops-and-Datasets-efficiency-question/m-p/114100#M31566</guid>
      <dc:creator>Patrick</dc:creator>
      <dc:date>2013-11-14T23:50:06Z</dc:date>
    </item>
    <item>
      <title>Re: Arryas, Loops and Datasets...efficiency question</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/Arryas-Loops-and-Datasets-efficiency-question/m-p/114101#M31567</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;And here an approach using a format.&lt;/P&gt;&lt;P&gt;I've also removed the "leave" statement in the loop as it is not needed. A "delete" has an implicit "return" so once the "delete" gets executed SAS starts immediately with the next iteration of the data step (an though not continuing any further looping).&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;data have;&lt;BR /&gt;&amp;nbsp; informat field1-field5 $2.;&lt;BR /&gt;&amp;nbsp; input id field1-field5;&lt;BR /&gt;&amp;nbsp; cards;&lt;BR /&gt;1 AA FF 11 12 CC&lt;BR /&gt;2 DD 25 14 XX YY&lt;BR /&gt;3 DD EE FF 25 CC&lt;BR /&gt;4 AA BB DD DD EE&lt;BR /&gt;;&lt;BR /&gt;run;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;data exclusion_list;&lt;BR /&gt;&amp;nbsp; input _excl_code :$2.;&lt;BR /&gt;&amp;nbsp; datalines;&lt;BR /&gt;AA&lt;BR /&gt;BB&lt;BR /&gt;;&lt;BR /&gt;run;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;/*create a format for exclusions */&lt;BR /&gt;data fmt_source;&lt;BR /&gt;&amp;nbsp; set exclusion_list (rename=(_excl_code=start)) end=last;&lt;BR /&gt;&amp;nbsp; retain fmtname '$Exclude' type 'c' label '1';&lt;BR /&gt;&amp;nbsp; output;&lt;BR /&gt;&amp;nbsp; if last then&lt;BR /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; do;&lt;BR /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; hlo='o';&lt;BR /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; label='0';&lt;BR /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; output;&lt;BR /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; end;&lt;BR /&gt;run;&lt;/P&gt;&lt;P&gt;proc format cntlin=fmt_source;&lt;BR /&gt;run;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;data want (drop=_:);&lt;BR /&gt;&amp;nbsp; set have;&lt;BR /&gt;&amp;nbsp; array&amp;nbsp; field{*} field1-field5;&lt;/P&gt;&lt;P&gt;&amp;nbsp; do _i = 1 to dim(field);&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; if put(field[_i],$Exclude.) = '1' then delete;&lt;BR /&gt;&amp;nbsp; end;&lt;BR /&gt;run;&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Fri, 15 Nov 2013 08:51:17 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/Arryas-Loops-and-Datasets-efficiency-question/m-p/114101#M31567</guid>
      <dc:creator>Patrick</dc:creator>
      <dc:date>2013-11-15T08:51:17Z</dc:date>
    </item>
  </channel>
</rss>

