<?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: Meaniing of:   if (0) then modify work.dataset in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/Meaniing-of-if-0-then-modify-work-dataset/m-p/899499#M355544</link>
    <description>Thank you &lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/19879"&gt;@Quentin&lt;/a&gt; for making me realize that it behaves like a PROC APPEND.</description>
    <pubDate>Sat, 21 Oct 2023 04:54:48 GMT</pubDate>
    <dc:creator>PopCorn14</dc:creator>
    <dc:date>2023-10-21T04:54:48Z</dc:date>
    <item>
      <title>Meaniing of:   if (0) then modify work.dataset</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Meaniing-of-if-0-then-modify-work-dataset/m-p/899458#M355519</link>
      <description>&lt;P&gt;Hi,&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;I found these lines of code in our big application but I really don't understand the first lines.&lt;/P&gt;
&lt;P&gt;I don't understand the condition "if (0) then modify" the output dataset.&lt;/P&gt;
&lt;P&gt;What is the purpose&amp;nbsp; of that modify at this location?&lt;/P&gt;
&lt;P&gt;Thank you so much for also giving an another example with if (0) then modify.....&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;data work.dataset;&lt;BR /&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; if (0) then modify work.dataset;&lt;/P&gt;
&lt;P&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; set work.processing(where=(indicator)) end=__Last__; &lt;BR /&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; retain __Count__ 0;&lt;BR /&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; __Count__ = __Count__ + 1; &lt;BR /&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp;output; &lt;BR /&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp;if (__Last__) then call symputx('incatorCount',__Count__);&lt;BR /&gt;run;&lt;/P&gt;</description>
      <pubDate>Fri, 20 Oct 2023 19:49:10 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Meaniing-of-if-0-then-modify-work-dataset/m-p/899458#M355519</guid>
      <dc:creator>PopCorn14</dc:creator>
      <dc:date>2023-10-20T19:49:10Z</dc:date>
    </item>
    <item>
      <title>Re: Meaniing of:   if (0) then modify work.dataset</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Meaniing-of-if-0-then-modify-work-dataset/m-p/899459#M355520</link>
      <description>&lt;P&gt;The part&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;if (0)&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;is never true, so this line will never do anything.&lt;/P&gt;</description>
      <pubDate>Fri, 20 Oct 2023 20:20:41 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Meaniing-of-if-0-then-modify-work-dataset/m-p/899459#M355520</guid>
      <dc:creator>PaigeMiller</dc:creator>
      <dc:date>2023-10-20T20:20:41Z</dc:date>
    </item>
    <item>
      <title>Re: Meaniing of:   if (0) then modify work.dataset</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Meaniing-of-if-0-then-modify-work-dataset/m-p/899463#M355523</link>
      <description>&lt;P&gt;Thank you Paige.&amp;nbsp; I understand that it will not execute but with a modify, I don't see what it does.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;We do use if (0) with hash table.&lt;/P&gt;
&lt;P&gt;Intead of using the length statement, we can use a non-executing SET statement .&lt;BR /&gt;&lt;BR /&gt;data country;&lt;BR /&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; if 0 then set orion.continent;&lt;BR /&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;if _n_=1 then do;&lt;BR /&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;declare hash&lt;BR /&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; ContName(dataset:'orion.continent');&lt;BR /&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; ContName.definekey('ContinentID');&lt;BR /&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;ContName.definedata('ContinentName');&lt;BR /&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; ContName.definedone(); &lt;BR /&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp;end;&lt;BR /&gt;&amp;nbsp; &amp;nbsp; set orion.country(keep=ContinentID Country&amp;nbsp; &amp;nbsp;CountryName);&lt;BR /&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp;if ContName.find()=0;&lt;BR /&gt;run;&lt;BR /&gt;&lt;BR /&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Therefore I don't know with modify if it has another purpose.&lt;/P&gt;</description>
      <pubDate>Fri, 20 Oct 2023 20:29:41 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Meaniing-of-if-0-then-modify-work-dataset/m-p/899463#M355523</guid>
      <dc:creator>PopCorn14</dc:creator>
      <dc:date>2023-10-20T20:29:41Z</dc:date>
    </item>
    <item>
      <title>Re: Meaniing of:   if (0) then modify work.dataset</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Meaniing-of-if-0-then-modify-work-dataset/m-p/899465#M355525</link>
      <description>&lt;P&gt;Hi,&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;If you are not sure what it does then you can try backing up the &lt;FONT face="courier new,courier"&gt;&lt;SPAN&gt;work.dataset&amp;nbsp;&lt;/SPAN&gt;&lt;/FONT&gt;data set, commenting out that &lt;FONT face="courier new,courier"&gt;if (0)&lt;/FONT&gt; line and running the code again with your data and then see what difference it makes by maybe running a proc compare between the data sets.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;This is a general principle that can be used in other scenarios too.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Thanks &amp;amp; kind regards,&lt;/P&gt;
&lt;P&gt;Amir.&lt;/P&gt;</description>
      <pubDate>Fri, 20 Oct 2023 20:41:02 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Meaniing-of-if-0-then-modify-work-dataset/m-p/899465#M355525</guid>
      <dc:creator>Amir</dc:creator>
      <dc:date>2023-10-20T20:41:02Z</dc:date>
    </item>
    <item>
      <title>Re: Meaniing of:   if (0) then modify work.dataset</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Meaniing-of-if-0-then-modify-work-dataset/m-p/899467#M355526</link>
      <description>&lt;P&gt;It's going to depend a bit on what the current content of the work.dataset might be.&lt;/P&gt;
&lt;P&gt;Basically modify means it will add records from the data set on the other SET to work.dataset.&lt;/P&gt;
&lt;P&gt;However since MODIFY does not allow adding variables to the data set then the _count_ variable is not added.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Depending on what you do with work.dataset later it looks like kludgy way to count observations to get a macro variable.&lt;/P&gt;</description>
      <pubDate>Fri, 20 Oct 2023 20:51:24 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Meaniing-of-if-0-then-modify-work-dataset/m-p/899467#M355526</guid>
      <dc:creator>ballardw</dc:creator>
      <dc:date>2023-10-20T20:51:24Z</dc:date>
    </item>
    <item>
      <title>Re: Meaniing of:   if (0) then modify work.dataset</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Meaniing-of-if-0-then-modify-work-dataset/m-p/899479#M355529</link>
      <description>&lt;P&gt;I don't use MODIFY much (ever?).&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Even though you have if (0), it's still working at compile time to make it update the dataset rather than over-write it, and it prevents the MODIFY statement from reading any data when the step executes.&amp;nbsp; It looks looks like it's basically similar to using PROC APPEND .&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;I played with code like:&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data want ;
 input x y $1.;
 cards ;
1 A
2 B
;

data foo ;
 input x ;
 cards ;
3
4
;
run ;

data want ;
  if 0 then modify want ;
  set foo ;
  output ;
run ;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;which returns:&lt;/P&gt;
&lt;PRE&gt;Obs    x    y

 1     1    A
 2     2    B
 3     3
 4     4
&lt;/PRE&gt;
&lt;P&gt;If you change to if (1) then modify want, it will return:&lt;/P&gt;
&lt;PRE&gt; Obs    x    y

  1     1    A
  2     2    B
  3     3    A
  4     4    B
&lt;/PRE&gt;</description>
      <pubDate>Fri, 20 Oct 2023 22:25:13 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Meaniing-of-if-0-then-modify-work-dataset/m-p/899479#M355529</guid>
      <dc:creator>Quentin</dc:creator>
      <dc:date>2023-10-20T22:25:13Z</dc:date>
    </item>
    <item>
      <title>Re: Meaniing of:   if (0) then modify work.dataset</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Meaniing-of-if-0-then-modify-work-dataset/m-p/899480#M355530</link>
      <description>&lt;P&gt;Since the&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt; if (0) then modify work.dataset;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;statement precedes the&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;set work.processing(where=(indicator)) end=__Last__;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;statement, the SAS DATA step compiler will build the program data vector with the variables from &lt;U&gt;work.dataset&lt;/U&gt; preceding the variables from &lt;U&gt;work.processing&lt;/U&gt;.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;And if they have the same variables (or have some common variables), those variables will be ordered corresponding to the order in &lt;U&gt;work.dataset&lt;/U&gt;, (not the order in &lt;U&gt;work.processing&lt;/U&gt;) since it was the first dataset name encountered.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Fri, 20 Oct 2023 22:33:41 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Meaniing-of-if-0-then-modify-work-dataset/m-p/899480#M355530</guid>
      <dc:creator>mkeintz</dc:creator>
      <dc:date>2023-10-20T22:33:41Z</dc:date>
    </item>
    <item>
      <title>Re: Meaniing of:   if (0) then modify work.dataset</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Meaniing-of-if-0-then-modify-work-dataset/m-p/899492#M355541</link>
      <description>&lt;P&gt;As already demonstrated by others this code creates the same data as a Proc Append with the force option would do.&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;proc append base=work.dataset data=work.processing(where=(indicator)) force;
run;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;Because it's done via a SAS datastep it also allows for additional logic in the same pass through the data.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;The code demonstrates that the one who implemented it has a very solid understanding of the SAS datastep BUT.... if that's not some SAS R&amp;amp;D provided and maintained piece of code in the bowels of some SAS solution then it's for me also an example how not to implement unless there is a very good reason to do so and then only with a lot of comment/documentation directly in the code.&lt;/P&gt;
&lt;P&gt;Writing code that's easy to understand and maintain is imho most of the time of higher importance than to potentially save a few seconds of runtime.&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Sat, 21 Oct 2023 02:23:02 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Meaniing-of-if-0-then-modify-work-dataset/m-p/899492#M355541</guid>
      <dc:creator>Patrick</dc:creator>
      <dc:date>2023-10-21T02:23:02Z</dc:date>
    </item>
    <item>
      <title>Re: Meaniing of:   if (0) then modify work.dataset</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Meaniing-of-if-0-then-modify-work-dataset/m-p/899497#M355542</link>
      <description>&lt;P&gt;Thank you very much&amp;nbsp;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/12447"&gt;@Patrick&lt;/a&gt;&amp;nbsp;.&lt;/P&gt;
&lt;P&gt;Yes indeed, I double-checked the code by playing with it and it does a Proc Append force without having all the warnings like:&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;WARNING: &lt;EM&gt;Variable X was not found on BASE file. The variable will not be added to the BASE file.&lt;/EM&gt;&lt;/P&gt;
&lt;P&gt;WARNING: Variable A was not found on DATA file.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;I do agree without good documentation, it is not worth it.&lt;/P&gt;</description>
      <pubDate>Sat, 21 Oct 2023 04:55:47 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Meaniing-of-if-0-then-modify-work-dataset/m-p/899497#M355542</guid>
      <dc:creator>PopCorn14</dc:creator>
      <dc:date>2023-10-21T04:55:47Z</dc:date>
    </item>
    <item>
      <title>Re: Meaniing of:   if (0) then modify work.dataset</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Meaniing-of-if-0-then-modify-work-dataset/m-p/899498#M355543</link>
      <description>Thank you &lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/31461"&gt;@mkeintz&lt;/a&gt; for the explanation about the compiler and pdv.</description>
      <pubDate>Sat, 21 Oct 2023 04:51:45 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Meaniing-of-if-0-then-modify-work-dataset/m-p/899498#M355543</guid>
      <dc:creator>PopCorn14</dc:creator>
      <dc:date>2023-10-21T04:51:45Z</dc:date>
    </item>
    <item>
      <title>Re: Meaniing of:   if (0) then modify work.dataset</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Meaniing-of-if-0-then-modify-work-dataset/m-p/899499#M355544</link>
      <description>Thank you &lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/19879"&gt;@Quentin&lt;/a&gt; for making me realize that it behaves like a PROC APPEND.</description>
      <pubDate>Sat, 21 Oct 2023 04:54:48 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Meaniing-of-if-0-then-modify-work-dataset/m-p/899499#M355544</guid>
      <dc:creator>PopCorn14</dc:creator>
      <dc:date>2023-10-21T04:54:48Z</dc:date>
    </item>
    <item>
      <title>Re: Meaniing of:   if (0) then modify work.dataset</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Meaniing-of-if-0-then-modify-work-dataset/m-p/899547#M355551</link>
      <description>&lt;P&gt;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/247133"&gt;@PopCorn14&lt;/a&gt;&amp;nbsp;You can suppress such warnings by adding the NOWARN option.&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;proc append base=work.dataset data=work.processing(where=(indicator)) force nowarn;
run;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Sun, 22 Oct 2023 01:19:34 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Meaniing-of-if-0-then-modify-work-dataset/m-p/899547#M355551</guid>
      <dc:creator>Patrick</dc:creator>
      <dc:date>2023-10-22T01:19:34Z</dc:date>
    </item>
    <item>
      <title>Re: Meaniing of:   if (0) then modify work.dataset</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Meaniing-of-if-0-then-modify-work-dataset/m-p/899637#M355573</link>
      <description>Oh even better. Merci &lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/12447"&gt;@Patrick&lt;/a&gt; for that option.</description>
      <pubDate>Mon, 23 Oct 2023 13:42:16 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Meaniing-of-if-0-then-modify-work-dataset/m-p/899637#M355573</guid>
      <dc:creator>PopCorn14</dc:creator>
      <dc:date>2023-10-23T13:42:16Z</dc:date>
    </item>
  </channel>
</rss>

