<?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: Confused about how a code run through all observations of a variable in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/Confused-about-how-a-code-run-through-all-observations-of-a/m-p/713726#M220234</link>
    <description>&lt;P&gt;I just made a few comments. Hope the code makes more sense now. Feel free to ask &lt;span class="lia-unicode-emoji" title=":slightly_smiling_face:"&gt;🙂&lt;/span&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data screen123489116    (drop=row)
     deleted (keep=row)
;
   set screen12348911;
   row=_n_;
   array delwords {84} $ 15 _temporary_ ('DUPLICATE', 'DUPL', 'DUP', 'DUPE','DULP', 'DUPLI',
'1000DUPL','XSQ','XET','ADR','GDR','PREFERRED','PF','PFD','PREF','PF','WARRANT','WARRANTS','WTS','WTS2','WARRT',
'DEB','DB','DCB','DEBT','DEBENTURES','DEBENTURE','RLST IT','INVESTMENT TRUST','INV TST','UNIT TRUST','UNT TST',
'TRUST UNITS','TST UNITS','TRUST UNIT','TST UNIT','UT','IT.','IT','500','BOND','DEFER','DEP','DEPY','ELKS','ETF','FUND','FD','IDX','INDEX','LP','MIPS','MITS','MITT','MPS','NIKKEI','NOTE',
'PERQS','PINES','PRTF','PTNS','PTSHP','QUIBS','QUIDS','RATE','RCPTS',
'RECEIPTS','REIT','RETUR','SCORE','SPDR','STRYPES','TOPRS','UNIT','UNT',
'UTS','WTS','XXXXX','YIELD','YLD','EXPIRED','EXPD','EXPIRY','EXPY');

do i= 1 to dim(delwords) until (f&amp;gt;0);       /* Iterate through the array until f &amp;gt; 0 (ENAME Contains the word)                                  */
 f=findw(ENAME,delwords[i],'','eir');       /* Set f equal to the position of the current word in the array in ENAME. If it is not there, f = 0 */
end;

if f&amp;gt;0 then do;                             /* If f &amp;gt; 0 (The word is in ENAME, do this                                  */
      output deleted;                       /* Output the observation to the deleted data set                           */
      delete;                               /* Go to the top of the data step (Strictly, you do not need this statement */
   end;

   else output screen123489116;             /* If f = 0 (The word is NOT in ENAME, do this                              */
run;&lt;/CODE&gt;&lt;/PRE&gt;</description>
    <pubDate>Sun, 24 Jan 2021 19:15:04 GMT</pubDate>
    <dc:creator>PeterClemmensen</dc:creator>
    <dc:date>2021-01-24T19:15:04Z</dc:date>
    <item>
      <title>Confused about how a code run through all observations of a variable</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Confused-about-how-a-code-run-through-all-observations-of-a/m-p/713723#M220232</link>
      <description>&lt;P&gt;Hi SAS Users,&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;I have the code below for filtering my data, it seems to work properly. However, I do not know how can it run through all observations of the variable &lt;STRONG&gt;ENAME&lt;/STRONG&gt;?&lt;/P&gt;
&lt;P&gt;So, the variable&lt;STRONG&gt; ENAME&lt;/STRONG&gt; has 15,000 observations, and I want to delete any observation of which &lt;STRONG&gt;ENAME&lt;/STRONG&gt; contains any word in array&lt;STRONG&gt; delwords&lt;/STRONG&gt;. I do not know which code in the code below tells SAS that we go through all observations of &lt;STRONG&gt;ENAME&lt;/STRONG&gt;.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data screen123489116    (drop=row)
     deleted (keep=row)
;
   set screen12348911;
   row=_n_;
   array delwords {84} $ 15 _temporary_ ('DUPLICATE', 'DUPL', 'DUP', 'DUPE','DULP', 'DUPLI',
'1000DUPL','XSQ','XET','ADR','GDR','PREFERRED','PF','PFD','PREF','PF','WARRANT','WARRANTS','WTS','WTS2','WARRT',
'DEB','DB','DCB','DEBT','DEBENTURES','DEBENTURE','RLST IT','INVESTMENT TRUST','INV TST','UNIT TRUST','UNT TST',
'TRUST UNITS','TST UNITS','TRUST UNIT','TST UNIT','UT','IT.','IT','500','BOND','DEFER','DEP','DEPY','ELKS','ETF','FUND','FD','IDX','INDEX','LP','MIPS','MITS','MITT','MPS','NIKKEI','NOTE',
'PERQS','PINES','PRTF','PTNS','PTSHP','QUIBS','QUIDS','RATE','RCPTS',
'RECEIPTS','REIT','RETUR','SCORE','SPDR','STRYPES','TOPRS','UNIT','UNT',
'UTS','WTS','XXXXX','YIELD','YLD','EXPIRED','EXPD','EXPIRY','EXPY');

do i= 1 to dim(delwords)until (f&amp;gt;0);
 f=findw(ENAME,delwords[i],'','eir');
end;
if f&amp;gt;0 then do;
      output deleted;
      delete;
   end;
   else output screen123489116;
run;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;Many thanks and warmest regards.&lt;/P&gt;
&lt;DIV id="eJOY__extension_root" class="eJOY__extension_root_class" style="all: unset;"&gt;&amp;nbsp;&lt;/DIV&gt;</description>
      <pubDate>Sun, 24 Jan 2021 19:04:52 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Confused-about-how-a-code-run-through-all-observations-of-a/m-p/713723#M220232</guid>
      <dc:creator>Phil_NZ</dc:creator>
      <dc:date>2021-01-24T19:04:52Z</dc:date>
    </item>
    <item>
      <title>Re: Confused about how a code run through all observations of a variable</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Confused-about-how-a-code-run-through-all-observations-of-a/m-p/713726#M220234</link>
      <description>&lt;P&gt;I just made a few comments. Hope the code makes more sense now. Feel free to ask &lt;span class="lia-unicode-emoji" title=":slightly_smiling_face:"&gt;🙂&lt;/span&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data screen123489116    (drop=row)
     deleted (keep=row)
;
   set screen12348911;
   row=_n_;
   array delwords {84} $ 15 _temporary_ ('DUPLICATE', 'DUPL', 'DUP', 'DUPE','DULP', 'DUPLI',
'1000DUPL','XSQ','XET','ADR','GDR','PREFERRED','PF','PFD','PREF','PF','WARRANT','WARRANTS','WTS','WTS2','WARRT',
'DEB','DB','DCB','DEBT','DEBENTURES','DEBENTURE','RLST IT','INVESTMENT TRUST','INV TST','UNIT TRUST','UNT TST',
'TRUST UNITS','TST UNITS','TRUST UNIT','TST UNIT','UT','IT.','IT','500','BOND','DEFER','DEP','DEPY','ELKS','ETF','FUND','FD','IDX','INDEX','LP','MIPS','MITS','MITT','MPS','NIKKEI','NOTE',
'PERQS','PINES','PRTF','PTNS','PTSHP','QUIBS','QUIDS','RATE','RCPTS',
'RECEIPTS','REIT','RETUR','SCORE','SPDR','STRYPES','TOPRS','UNIT','UNT',
'UTS','WTS','XXXXX','YIELD','YLD','EXPIRED','EXPD','EXPIRY','EXPY');

do i= 1 to dim(delwords) until (f&amp;gt;0);       /* Iterate through the array until f &amp;gt; 0 (ENAME Contains the word)                                  */
 f=findw(ENAME,delwords[i],'','eir');       /* Set f equal to the position of the current word in the array in ENAME. If it is not there, f = 0 */
end;

if f&amp;gt;0 then do;                             /* If f &amp;gt; 0 (The word is in ENAME, do this                                  */
      output deleted;                       /* Output the observation to the deleted data set                           */
      delete;                               /* Go to the top of the data step (Strictly, you do not need this statement */
   end;

   else output screen123489116;             /* If f = 0 (The word is NOT in ENAME, do this                              */
run;&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Sun, 24 Jan 2021 19:15:04 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Confused-about-how-a-code-run-through-all-observations-of-a/m-p/713726#M220234</guid>
      <dc:creator>PeterClemmensen</dc:creator>
      <dc:date>2021-01-24T19:15:04Z</dc:date>
    </item>
    <item>
      <title>Re: Confused about how a code run through all observations of a variable</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Confused-about-how-a-code-run-through-all-observations-of-a/m-p/713730#M220236</link>
      <description>&lt;P&gt;Hi&amp;nbsp;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/31304"&gt;@PeterClemmensen&lt;/a&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Thank you very much for your note, I understand the meaning of the code! However, my point here is, which line of code of the code above tells SAS that we need to run through all observations of ENAME (from 1 to 15000) ?&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;And it is quite interesting about this code&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;delete;                               /* Go to the top of the data step (Strictly, you do not need this statement */&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;So, you mean the code I wrote, if the observation contains the word in array, it will be written in output "deleted", if not, it will be written in "screen123489116", so we do not need to delete this observation, am I correct?&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Many thanks and warmest regards!&lt;/P&gt;
&lt;DIV id="eJOY__extension_root" class="eJOY__extension_root_class" style="all: unset;"&gt;&amp;nbsp;&lt;/DIV&gt;</description>
      <pubDate>Sun, 24 Jan 2021 19:28:36 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Confused-about-how-a-code-run-through-all-observations-of-a/m-p/713730#M220236</guid>
      <dc:creator>Phil_NZ</dc:creator>
      <dc:date>2021-01-24T19:28:36Z</dc:date>
    </item>
    <item>
      <title>Re: Confused about how a code run through all observations of a variable</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Confused-about-how-a-code-run-through-all-observations-of-a/m-p/713731#M220237</link>
      <description>&lt;P&gt;This statement&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;   set screen12348911;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;Tells the data step to read all observations from the screen12348911 data set. I think that is what you're asking.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Yes, correct. As the &lt;A href="https://documentation.sas.com/?cdcId=pgmsascdc&amp;amp;cdcVersion=9.4_3.5&amp;amp;docsetId=lestmtsref&amp;amp;docsetTarget=p068vr83ld69mrn1fpvs67k5l5as.htm&amp;amp;locale=en" target="_self"&gt;Delete Statement Documentation&lt;/A&gt; says: &lt;EM&gt;"When DELETE executes, the current observation is not written to a data set, and SAS returns immediately to the beginning of the DATA step for the next iteration."&amp;nbsp;&lt;/EM&gt;. You can leave it in for whatever little performance it may give you, but it is not necessary. All it does is return to the top of the data step, which happens anyways at the bottom of the data step.&lt;/P&gt;</description>
      <pubDate>Sun, 24 Jan 2021 19:34:56 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Confused-about-how-a-code-run-through-all-observations-of-a/m-p/713731#M220237</guid>
      <dc:creator>PeterClemmensen</dc:creator>
      <dc:date>2021-01-24T19:34:56Z</dc:date>
    </item>
  </channel>
</rss>

