<?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 of colon after a comparison operator in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/Use-of-colon-after-a-comparison-operator/m-p/923150#M363464</link>
    <description>&lt;P&gt;Explain, please. What is wrong with the results in the log? What is the expected result?&lt;/P&gt;</description>
    <pubDate>Fri, 05 Apr 2024 11:55:33 GMT</pubDate>
    <dc:creator>PaigeMiller</dc:creator>
    <dc:date>2024-04-05T11:55:33Z</dc:date>
    <item>
      <title>Use of colon after a comparison operator</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Use-of-colon-after-a-comparison-operator/m-p/923144#M363461</link>
      <description>&lt;P&gt;Hi,&amp;nbsp;&lt;/P&gt;
&lt;P&gt;can you guys explain why the colon seems not to trim the dates before comparing and why I get more errors than warnings here?&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data test;
input rfxstdtc $ 1-10 impdtc $ 12-21 usubjid $ 23-30;
cards;
2023-10-12 2023-11-12 DEU-001F
2023-10    2023-10-13 DEU-001F
2023       2023-10-14 DEU-001F
2023-11    2023-10-13 DEU-001F
run;
data test1;
   set test;
   if rfxstdtc^='' and impdtc^='' and rfxstdtc ^=: impdtc then put 'E' 'RROR:# Imputation occurred on different partials dates ' _N_= USUBJID= rfxstdtc= impdtc= ; 
   if rfxstdtc^='' and impdtc^='' and strip(rfxstdtc) ^=: strip(impdtc) then put 'W' 'ARNING:# Imputation occurred on different partials dates ' _N_= USUBJID= rfxstdtc= impdtc= ; 
run;&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Fri, 05 Apr 2024 11:05:32 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Use-of-colon-after-a-comparison-operator/m-p/923144#M363461</guid>
      <dc:creator>Oligolas</dc:creator>
      <dc:date>2024-04-05T11:05:32Z</dc:date>
    </item>
    <item>
      <title>Re: Use of colon after a comparison operator</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Use-of-colon-after-a-comparison-operator/m-p/923150#M363464</link>
      <description>&lt;P&gt;Explain, please. What is wrong with the results in the log? What is the expected result?&lt;/P&gt;</description>
      <pubDate>Fri, 05 Apr 2024 11:55:33 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Use-of-colon-after-a-comparison-operator/m-p/923150#M363464</guid>
      <dc:creator>PaigeMiller</dc:creator>
      <dc:date>2024-04-05T11:55:33Z</dc:date>
    </item>
    <item>
      <title>Re: Use of colon after a comparison operator</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Use-of-colon-after-a-comparison-operator/m-p/923154#M363466</link>
      <description>&lt;P&gt;Hi&amp;nbsp;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/77163"&gt;@Oligolas&lt;/a&gt;,&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;The comparison is restricted to the length of the shorter string, &lt;EM&gt;including trailing blanks&lt;/EM&gt;, if any.&lt;/P&gt;
&lt;P&gt;Example:&lt;/P&gt;
&lt;PRE&gt;436   data _null_;
437   if 'AB' =:'ABC'  then put 'true1';
438   if 'AB '=:'ABC'  then put 'false';
439   if 'AB '=:'AB C' then put 'true2';
440   run;

true1
true2&lt;/PRE&gt;
&lt;P&gt;The first comparison looks at &lt;EM&gt;two&lt;/EM&gt; characters, the second and third comparison include &lt;EM&gt;three&lt;/EM&gt;.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Your&amp;nbsp;&lt;FONT face="courier new,courier"&gt;rfxstdtc&lt;/FONT&gt;&amp;nbsp;and &lt;FONT face="courier new,courier"&gt;impdtc&lt;/FONT&gt; values contain &lt;EM&gt;ten&lt;/EM&gt; characters since 10 is the defined length of both variables, so the comparisons without STRIP (or TRIM) are based on all ten characters. The expressions returned by the STRIP function are shorter if (leading or) trailing blanks were present in the arguments, so the comparisons change correspondingly.&lt;/P&gt;</description>
      <pubDate>Fri, 05 Apr 2024 12:11:52 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Use-of-colon-after-a-comparison-operator/m-p/923154#M363466</guid>
      <dc:creator>FreelanceReinh</dc:creator>
      <dc:date>2024-04-05T12:11:52Z</dc:date>
    </item>
    <item>
      <title>Re: Use of colon after a comparison operator</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Use-of-colon-after-a-comparison-operator/m-p/923201#M363483</link>
      <description>&lt;P&gt;Why would you use STRIP() instead of TRIM()?&lt;/P&gt;
&lt;P&gt;Do you expect the values to have leading spaces?&amp;nbsp; And if so why do you want to remove the leading spaces?&lt;/P&gt;</description>
      <pubDate>Fri, 05 Apr 2024 15:54:56 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Use-of-colon-after-a-comparison-operator/m-p/923201#M363483</guid>
      <dc:creator>Tom</dc:creator>
      <dc:date>2024-04-05T15:54:56Z</dc:date>
    </item>
    <item>
      <title>Re: Use of colon after a comparison operator</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Use-of-colon-after-a-comparison-operator/m-p/923760#M363657</link>
      <description>&lt;P&gt;Hi&amp;nbsp;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/159"&gt;@Tom&lt;/a&gt;&amp;nbsp;I do not 'expect' it, I only use strip as a standard to compare strings&lt;/P&gt;</description>
      <pubDate>Wed, 10 Apr 2024 09:07:20 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Use-of-colon-after-a-comparison-operator/m-p/923760#M363657</guid>
      <dc:creator>Oligolas</dc:creator>
      <dc:date>2024-04-10T09:07:20Z</dc:date>
    </item>
    <item>
      <title>Re: Use of colon after a comparison operator</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Use-of-colon-after-a-comparison-operator/m-p/923761#M363658</link>
      <description>&lt;P&gt;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/10892"&gt;@PaigeMiller&lt;/a&gt;&amp;nbsp;I obviously took a statement in a &lt;A href="https://support.sas.com/resources/papers/proceedings/proceedings/sugi29/040-29.pdf" target="_blank" rel="noopener"&gt;paper&lt;/A&gt; 'as is' without checking it's validity or I simply misunderstood it&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;"These operators compare two strings &lt;STRONG&gt;after making the strings the same length&lt;/STRONG&gt; by truncating the longer string to the same length as&amp;nbsp;the shorter string."&lt;/P&gt;</description>
      <pubDate>Wed, 10 Apr 2024 09:13:07 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Use-of-colon-after-a-comparison-operator/m-p/923761#M363658</guid>
      <dc:creator>Oligolas</dc:creator>
      <dc:date>2024-04-10T09:13:07Z</dc:date>
    </item>
  </channel>
</rss>

