<?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: can you detect errors in this code? i do not know what does not work in New SAS User</title>
    <link>https://communities.sas.com/t5/New-SAS-User/can-you-detect-errors-in-this-code-i-do-not-know-what-does-not/m-p/846667#M36909</link>
    <description>&lt;P&gt;Your logical structure is equivalent to&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;BLOCKQUOTE&gt;
&lt;P&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; if A then create results ;&lt;/P&gt;
&lt;P&gt;else if B then create results;&lt;/P&gt;
&lt;P&gt;else if C then create results;&lt;/P&gt;
&lt;P&gt;else if D then create results;&lt;/P&gt;
&lt;/BLOCKQUOTE&gt;
&lt;P&gt;Even though you are using "else if" syntax, the set of observations that would satisfy the above would be this intersection:&lt;/P&gt;
&lt;P&gt;&amp;nbsp; &amp;nbsp;&lt;STRONG&gt;A&amp;nbsp;∩ B&amp;nbsp;∩ C&amp;nbsp;∩ D&lt;/STRONG&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;If your log shows no errors messages, yet you have no observation with values for the result variables, then every obs in your dataset falls outside the above intersection.&amp;nbsp; So, by&lt;A href="https://en.wikipedia.org/wiki/De_Morgan%27s_laws" target="_self"&gt; De Morgan's Laws&lt;/A&gt;&amp;nbsp;all of your observations fall in the complement, characterized by&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&lt;STRONG&gt;&amp;nbsp; &amp;nbsp;(not A)&amp;nbsp;∪ (not B) ∪ (not C) ∪ (not D)&lt;/STRONG&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;(where&amp;nbsp;&lt;EM&gt;∪&lt;/EM&gt; is the union set operator and is equivalent to &lt;EM&gt;&lt;STRONG&gt;and&lt;/STRONG&gt;&lt;/EM&gt; in any subsetting syntax in SAS.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Now, in your case&lt;/P&gt;
&lt;BLOCKQUOTE&gt;
&lt;P&gt;condition &lt;EM&gt;&lt;STRONG&gt;A&lt;/STRONG&gt;&lt;/EM&gt;&amp;nbsp; &amp;lt;==&amp;gt;&amp;nbsp; &lt;EM&gt;&lt;STRONG&gt;cond not in (0)&lt;/STRONG&gt;&lt;/EM&gt;&lt;/P&gt;
&lt;P&gt;condition &lt;EM&gt;&lt;STRONG&gt;B&lt;/STRONG&gt;&lt;/EM&gt;&amp;nbsp; &amp;lt;==&amp;gt;&amp;nbsp; &lt;EM&gt;&lt;STRONG&gt;cond_1 &amp;gt; 30&lt;/STRONG&gt;&lt;/EM&gt;&lt;/P&gt;
&lt;P&gt;condition &lt;EM&gt;&lt;STRONG&gt;C&lt;/STRONG&gt;&lt;/EM&gt;&amp;nbsp; &amp;lt;==&amp;gt;&amp;nbsp; &lt;EM&gt;&lt;STRONG&gt;cond_2&amp;gt;soglia&lt;/STRONG&gt;&lt;/EM&gt;&lt;/P&gt;
&lt;P&gt;condition &lt;EM&gt;&lt;STRONG&gt;D&lt;/STRONG&gt;&lt;/EM&gt;&amp;nbsp; &amp;lt;==&amp;gt;&amp;nbsp; &lt;EM&gt;&lt;STRONG&gt;cond_3="Stage 1"&lt;/STRONG&gt;&lt;/EM&gt;&lt;/P&gt;
&lt;/BLOCKQUOTE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;which means that all of your observations must have&lt;/P&gt;
&lt;BLOCKQUOTE&gt;
&lt;P&gt;cond in (0) &lt;STRONG&gt;and&lt;/STRONG&gt;&lt;/P&gt;
&lt;P&gt;cond_1&amp;lt;=30 &lt;STRONG&gt;and&lt;/STRONG&gt;&lt;/P&gt;
&lt;P&gt;cond_2&amp;lt;=soglia &lt;STRONG&gt;and&lt;/STRONG&gt;&lt;/P&gt;
&lt;P&gt;cond_3 ^="Stage 1"&lt;/P&gt;
&lt;/BLOCKQUOTE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
    <pubDate>Mon, 28 Nov 2022 18:49:44 GMT</pubDate>
    <dc:creator>mkeintz</dc:creator>
    <dc:date>2022-11-28T18:49:44Z</dc:date>
    <item>
      <title>can you detect errors in this code? i do not know what does not work</title>
      <link>https://communities.sas.com/t5/New-SAS-User/can-you-detect-errors-in-this-code-i-do-not-know-what-does-not/m-p/846657#M36907</link>
      <description>&lt;PRE&gt;&lt;CODE class=""&gt;data final_dataset;
set initial_dataset;
length variable $50.;
if cond not in (0) then do; 
	variable_1="S2";
	variable="xxx";
end;
else if cond_1 &amp;gt; 30 then do;
	variable_1="S2";
	variable="xxy";
	end;
else if cond_2 &amp;gt; soglia then do;
	variable_1 ="S2";
	variable="xyy";
	end;
else if cond_3="Stage 1" then do;
	variable="yyy";
	end;
run;&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;the problem is that, when i print the result, the new column i created named "variable" is empty. i cannot understand why&lt;/P&gt;</description>
      <pubDate>Mon, 28 Nov 2022 18:06:04 GMT</pubDate>
      <guid>https://communities.sas.com/t5/New-SAS-User/can-you-detect-errors-in-this-code-i-do-not-know-what-does-not/m-p/846657#M36907</guid>
      <dc:creator>ari2495</dc:creator>
      <dc:date>2022-11-28T18:06:04Z</dc:date>
    </item>
    <item>
      <title>Re: can you detect errors in this code? i do not know what does not work</title>
      <link>https://communities.sas.com/t5/New-SAS-User/can-you-detect-errors-in-this-code-i-do-not-know-what-does-not/m-p/846659#M36908</link>
      <description>&lt;P&gt;Your code looks fine. The problem is likely in the initial_dataset data.&lt;/P&gt;</description>
      <pubDate>Mon, 28 Nov 2022 18:09:13 GMT</pubDate>
      <guid>https://communities.sas.com/t5/New-SAS-User/can-you-detect-errors-in-this-code-i-do-not-know-what-does-not/m-p/846659#M36908</guid>
      <dc:creator>PeterClemmensen</dc:creator>
      <dc:date>2022-11-28T18:09:13Z</dc:date>
    </item>
    <item>
      <title>Re: can you detect errors in this code? i do not know what does not work</title>
      <link>https://communities.sas.com/t5/New-SAS-User/can-you-detect-errors-in-this-code-i-do-not-know-what-does-not/m-p/846667#M36909</link>
      <description>&lt;P&gt;Your logical structure is equivalent to&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;BLOCKQUOTE&gt;
&lt;P&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; if A then create results ;&lt;/P&gt;
&lt;P&gt;else if B then create results;&lt;/P&gt;
&lt;P&gt;else if C then create results;&lt;/P&gt;
&lt;P&gt;else if D then create results;&lt;/P&gt;
&lt;/BLOCKQUOTE&gt;
&lt;P&gt;Even though you are using "else if" syntax, the set of observations that would satisfy the above would be this intersection:&lt;/P&gt;
&lt;P&gt;&amp;nbsp; &amp;nbsp;&lt;STRONG&gt;A&amp;nbsp;∩ B&amp;nbsp;∩ C&amp;nbsp;∩ D&lt;/STRONG&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;If your log shows no errors messages, yet you have no observation with values for the result variables, then every obs in your dataset falls outside the above intersection.&amp;nbsp; So, by&lt;A href="https://en.wikipedia.org/wiki/De_Morgan%27s_laws" target="_self"&gt; De Morgan's Laws&lt;/A&gt;&amp;nbsp;all of your observations fall in the complement, characterized by&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&lt;STRONG&gt;&amp;nbsp; &amp;nbsp;(not A)&amp;nbsp;∪ (not B) ∪ (not C) ∪ (not D)&lt;/STRONG&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;(where&amp;nbsp;&lt;EM&gt;∪&lt;/EM&gt; is the union set operator and is equivalent to &lt;EM&gt;&lt;STRONG&gt;and&lt;/STRONG&gt;&lt;/EM&gt; in any subsetting syntax in SAS.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Now, in your case&lt;/P&gt;
&lt;BLOCKQUOTE&gt;
&lt;P&gt;condition &lt;EM&gt;&lt;STRONG&gt;A&lt;/STRONG&gt;&lt;/EM&gt;&amp;nbsp; &amp;lt;==&amp;gt;&amp;nbsp; &lt;EM&gt;&lt;STRONG&gt;cond not in (0)&lt;/STRONG&gt;&lt;/EM&gt;&lt;/P&gt;
&lt;P&gt;condition &lt;EM&gt;&lt;STRONG&gt;B&lt;/STRONG&gt;&lt;/EM&gt;&amp;nbsp; &amp;lt;==&amp;gt;&amp;nbsp; &lt;EM&gt;&lt;STRONG&gt;cond_1 &amp;gt; 30&lt;/STRONG&gt;&lt;/EM&gt;&lt;/P&gt;
&lt;P&gt;condition &lt;EM&gt;&lt;STRONG&gt;C&lt;/STRONG&gt;&lt;/EM&gt;&amp;nbsp; &amp;lt;==&amp;gt;&amp;nbsp; &lt;EM&gt;&lt;STRONG&gt;cond_2&amp;gt;soglia&lt;/STRONG&gt;&lt;/EM&gt;&lt;/P&gt;
&lt;P&gt;condition &lt;EM&gt;&lt;STRONG&gt;D&lt;/STRONG&gt;&lt;/EM&gt;&amp;nbsp; &amp;lt;==&amp;gt;&amp;nbsp; &lt;EM&gt;&lt;STRONG&gt;cond_3="Stage 1"&lt;/STRONG&gt;&lt;/EM&gt;&lt;/P&gt;
&lt;/BLOCKQUOTE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;which means that all of your observations must have&lt;/P&gt;
&lt;BLOCKQUOTE&gt;
&lt;P&gt;cond in (0) &lt;STRONG&gt;and&lt;/STRONG&gt;&lt;/P&gt;
&lt;P&gt;cond_1&amp;lt;=30 &lt;STRONG&gt;and&lt;/STRONG&gt;&lt;/P&gt;
&lt;P&gt;cond_2&amp;lt;=soglia &lt;STRONG&gt;and&lt;/STRONG&gt;&lt;/P&gt;
&lt;P&gt;cond_3 ^="Stage 1"&lt;/P&gt;
&lt;/BLOCKQUOTE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Mon, 28 Nov 2022 18:49:44 GMT</pubDate>
      <guid>https://communities.sas.com/t5/New-SAS-User/can-you-detect-errors-in-this-code-i-do-not-know-what-does-not/m-p/846667#M36909</guid>
      <dc:creator>mkeintz</dc:creator>
      <dc:date>2022-11-28T18:49:44Z</dc:date>
    </item>
    <item>
      <title>Re: can you detect errors in this code? i do not know what does not work</title>
      <link>https://communities.sas.com/t5/New-SAS-User/can-you-detect-errors-in-this-code-i-do-not-know-what-does-not/m-p/846672#M36910</link>
      <description>&lt;P&gt;PROC FREQ will help you find what is wrong with your logic, given there are no syntax errors in your code:&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;proc freq data = initial_dataset;
  table cond * cond_1 * cond_2 * cond_3 / missing list;
run;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;Examine the combination of values shown in the output.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Mon, 28 Nov 2022 19:07:16 GMT</pubDate>
      <guid>https://communities.sas.com/t5/New-SAS-User/can-you-detect-errors-in-this-code-i-do-not-know-what-does-not/m-p/846672#M36910</guid>
      <dc:creator>SASKiwi</dc:creator>
      <dc:date>2022-11-28T19:07:16Z</dc:date>
    </item>
    <item>
      <title>Re: can you detect errors in this code? i do not know what does not work</title>
      <link>https://communities.sas.com/t5/New-SAS-User/can-you-detect-errors-in-this-code-i-do-not-know-what-does-not/m-p/846679#M36911</link>
      <description>&lt;P&gt;Did SAS print any notes about uninitialized variables?&amp;nbsp; Do you really have the variables you are referencing:&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;cond cond_1 cond_2 soglia cond_3&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;If there are such notes then fix issue first.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Otherwise look at the actual values of the variables you are testing.&lt;/P&gt;
&lt;P&gt;For example try running this PROC FREQ and see what it tells you.&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;proc freq data= initial_dataset;
  tables cond*cond_1*cond_2*soglia*cond_3 / list missing;
run;
&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;Are there any rows output that meet your conditions?&lt;/P&gt;</description>
      <pubDate>Mon, 28 Nov 2022 19:45:23 GMT</pubDate>
      <guid>https://communities.sas.com/t5/New-SAS-User/can-you-detect-errors-in-this-code-i-do-not-know-what-does-not/m-p/846679#M36911</guid>
      <dc:creator>Tom</dc:creator>
      <dc:date>2022-11-28T19:45:23Z</dc:date>
    </item>
    <item>
      <title>Re: can you detect errors in this code? i do not know what does not work</title>
      <link>https://communities.sas.com/t5/New-SAS-User/can-you-detect-errors-in-this-code-i-do-not-know-what-does-not/m-p/846752#M36917</link>
      <description>I really have to thank you all for all&lt;BR /&gt;Your answers; I detected that the problem was with the last “then do”; simply eliminating it the code worked well again. Many thanks!</description>
      <pubDate>Tue, 29 Nov 2022 07:09:54 GMT</pubDate>
      <guid>https://communities.sas.com/t5/New-SAS-User/can-you-detect-errors-in-this-code-i-do-not-know-what-does-not/m-p/846752#M36917</guid>
      <dc:creator>ari2495</dc:creator>
      <dc:date>2022-11-29T07:09:54Z</dc:date>
    </item>
  </channel>
</rss>

