<?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: Use string comparison in IF/ELSE in SAS Procedures</title>
    <link>https://communities.sas.com/t5/SAS-Procedures/Use-string-comparison-in-IF-ELSE/m-p/874457#M82716</link>
    <description>Got it, didn't realize that &amp;amp; needs to be deleted.</description>
    <pubDate>Mon, 08 May 2023 13:46:40 GMT</pubDate>
    <dc:creator>Laura1890</dc:creator>
    <dc:date>2023-05-08T13:46:40Z</dc:date>
    <item>
      <title>Use string comparison in IF/ELSE</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/Use-string-comparison-in-IF-ELSE/m-p/874425#M82711</link>
      <description>&lt;P&gt;Hello community,&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I am desperately trying to set up an IF/ELSE where the if-condition is based on a string comparison. If the variable is not equal to PRODET (I also tried 'PRODET') I want the macro to be executed. This is what looked pretty reasonable to me, but we tried various options.&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;DATA _NULL_;&lt;BR /&gt;IF (&amp;amp;v_modul_akt. NE PRODET)&lt;BR /&gt;THEN CALL EXECUTE ('%set_module_view');&lt;BR /&gt;RUN;&lt;/P&gt;</description>
      <pubDate>Mon, 08 May 2023 11:06:47 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/Use-string-comparison-in-IF-ELSE/m-p/874425#M82711</guid>
      <dc:creator>Laura1890</dc:creator>
      <dc:date>2023-05-08T11:06:47Z</dc:date>
    </item>
    <item>
      <title>Re: Use string comparison in IF/ELSE</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/Use-string-comparison-in-IF-ELSE/m-p/874433#M82712</link>
      <description>&lt;P&gt;Text without quotes around it is interpreted as code. So in your program, both the text resolved from &lt;STRONG&gt;&amp;amp;v_module_akt.&lt;/STRONG&gt; an the word &lt;STRONG&gt;PRODET&lt;/STRONG&gt; are both interpreted as variable names:&lt;/P&gt;
&lt;PRE&gt;&lt;SPAN&gt;DATA _NULL_;&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;   IF (&amp;amp;v_modul_akt. NE PRODET)&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;   THEN CALL EXECUTE ('%set_module_view');&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;RUN;&lt;/SPAN&gt;&lt;BR /&gt;&lt;CODE class=" language-sas"&gt;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;Sinc nothing in the program assigns a value to those variables, they are both missing, so the values&amp;nbsp;&lt;EM&gt;are&lt;/EM&gt; equal. In your log you should see a NOTE indicating that the variables are uninitialized.&lt;BR /&gt;Try this instead:&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;DATA _NULL_;
   IF ("&amp;amp;v_modul_akt." NE "PRODET")
   THEN CALL EXECUTE ('%set_module_view');
RUN;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;And may the SAS be with&amp;nbsp; you!&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Mon, 08 May 2023 11:53:23 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/Use-string-comparison-in-IF-ELSE/m-p/874433#M82712</guid>
      <dc:creator>SASJedi</dc:creator>
      <dc:date>2023-05-08T11:53:23Z</dc:date>
    </item>
    <item>
      <title>Re: Use string comparison in IF/ELSE</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/Use-string-comparison-in-IF-ELSE/m-p/874436#M82713</link>
      <description>&lt;P&gt;I would even go 1 step further and do:&lt;/P&gt;
&lt;LI-CODE lang="sas"&gt;DATA _NULL_;
   IF symget("v_modul_akt") NE "PRODET")
   THEN CALL EXECUTE ('%set_module_view');
RUN;&lt;/LI-CODE&gt;
&lt;P&gt;to ensure that "strange" value of&amp;nbsp;v_modul_akt won't blow up my sas &lt;span class="lia-unicode-emoji" title=":slightly_smiling_face:"&gt;🙂&lt;/span&gt;&lt;/P&gt;</description>
      <pubDate>Mon, 08 May 2023 12:05:13 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/Use-string-comparison-in-IF-ELSE/m-p/874436#M82713</guid>
      <dc:creator>yabwon</dc:creator>
      <dc:date>2023-05-08T12:05:13Z</dc:date>
    </item>
    <item>
      <title>Re: Use string comparison in IF/ELSE</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/Use-string-comparison-in-IF-ELSE/m-p/874446#M82714</link>
      <description>&lt;P&gt;Thanks for the help!&amp;nbsp;&lt;/P&gt;&lt;P&gt;Unfortunately, I still struggle:&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;%LET v_modul_akt = PRODET;&lt;BR /&gt;DATA _NULL_;&lt;BR /&gt;IF (symget("&amp;amp;v_modul_akt.") NE "PRODET")&lt;BR /&gt;THEN CALL EXECUTE ('%set_module_view');&lt;BR /&gt;RUN;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;This snippet still calls the macro, even though the if-statement says "PRODET" NE "PRODET"&lt;/P&gt;</description>
      <pubDate>Mon, 08 May 2023 13:01:21 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/Use-string-comparison-in-IF-ELSE/m-p/874446#M82714</guid>
      <dc:creator>Laura1890</dc:creator>
      <dc:date>2023-05-08T13:01:21Z</dc:date>
    </item>
    <item>
      <title>Re: Use string comparison in IF/ELSE</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/Use-string-comparison-in-IF-ELSE/m-p/874449#M82715</link>
      <description>&lt;P&gt;Read the code I typed...&lt;/P&gt;</description>
      <pubDate>Mon, 08 May 2023 13:08:03 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/Use-string-comparison-in-IF-ELSE/m-p/874449#M82715</guid>
      <dc:creator>yabwon</dc:creator>
      <dc:date>2023-05-08T13:08:03Z</dc:date>
    </item>
    <item>
      <title>Re: Use string comparison in IF/ELSE</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/Use-string-comparison-in-IF-ELSE/m-p/874457#M82716</link>
      <description>Got it, didn't realize that &amp;amp; needs to be deleted.</description>
      <pubDate>Mon, 08 May 2023 13:46:40 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/Use-string-comparison-in-IF-ELSE/m-p/874457#M82716</guid>
      <dc:creator>Laura1890</dc:creator>
      <dc:date>2023-05-08T13:46:40Z</dc:date>
    </item>
  </channel>
</rss>

