<?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: Format problem in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/Format-problem/m-p/709455#M218168</link>
    <description>&lt;P&gt;By any chance, are you after - FIND substring in a string search?&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&lt;STRONG&gt;want=^^index(b,a);&lt;/STRONG&gt;&lt;/P&gt;</description>
    <pubDate>Tue, 05 Jan 2021 16:31:38 GMT</pubDate>
    <dc:creator>novinosrin</dc:creator>
    <dc:date>2021-01-05T16:31:38Z</dc:date>
    <item>
      <title>Format problem</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Format-problem/m-p/709454#M218167</link>
      <description>&lt;P&gt;Hello,&lt;/P&gt;
&lt;P&gt;I'd like to create a "top" variable that is equal to 1 when A=/= B and 0 otherwise.&lt;BR /&gt;&lt;BR /&gt;As you can see in the attached dataset, for line 10 and 11, A=B (="XXX") but because the length is different , the "top" ( TPRGLTRM) doesn't work. Here is how i constructed the TP :&amp;nbsp;&lt;/P&gt;
&lt;P&gt;TPRGLTRM = (COQREGLETRM ne REGLETRM)&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Any idea to sort it out for when A and B are both equal to "XXX" ?&lt;/P&gt;</description>
      <pubDate>Tue, 05 Jan 2021 16:23:11 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Format-problem/m-p/709454#M218167</guid>
      <dc:creator>Mathis1</dc:creator>
      <dc:date>2021-01-05T16:23:11Z</dc:date>
    </item>
    <item>
      <title>Re: Format problem</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Format-problem/m-p/709455#M218168</link>
      <description>&lt;P&gt;By any chance, are you after - FIND substring in a string search?&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&lt;STRONG&gt;want=^^index(b,a);&lt;/STRONG&gt;&lt;/P&gt;</description>
      <pubDate>Tue, 05 Jan 2021 16:31:38 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Format-problem/m-p/709455#M218168</guid>
      <dc:creator>novinosrin</dc:creator>
      <dc:date>2021-01-05T16:31:38Z</dc:date>
    </item>
    <item>
      <title>Re: Format problem</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Format-problem/m-p/709461#M218171</link>
      <description>&lt;P&gt;SAS Formats apply to single variables.&lt;/P&gt;
&lt;P&gt;Anything involving two or more variables basically requires you to create a variable for a format that can have a format applied.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;SAS will report 'XXX' as equal to "XXX&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; " unless the extra characters are not blanks or there is a leading blank. Example:&lt;/P&gt;
&lt;PRE&gt;data junk;
   x='xxx';
   y='xxx     ';
   z= (x ne y);
run;&lt;/PRE&gt;
&lt;P&gt;Which has Z = 0&amp;nbsp; or in other words x is equal to y.&lt;/P&gt;
&lt;P&gt;So one suspects there are more details that you have not shared. The code you show uses two variables that do not exist in the example data set so is not very helpful.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Tue, 05 Jan 2021 16:53:12 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Format-problem/m-p/709461#M218171</guid>
      <dc:creator>ballardw</dc:creator>
      <dc:date>2021-01-05T16:53:12Z</dc:date>
    </item>
    <item>
      <title>Re: Format problem</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Format-problem/m-p/709467#M218173</link>
      <description>&lt;P&gt;Are you asking how to test of both A and B are equal to the text XXX?&lt;/P&gt;
&lt;P&gt;So if you have this data:&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data forum ;
  infile datalines dsd dlm='|' truncover;
  input COLFORMULE :$2. A :$4. B :$8. TPRGLTRM ;
  label COLFORMULE='CO-Code Formule'
        A='CO - Règle Evolution - Terme'
        B='Cas de revalorisation'
        TPRGLTRM='Top écart sur la règle au terme'
  ;
datalines4;
A5|4RH5|10305RH5|1
A5|4RH1|10305RH1|1
A5|4RH4|10305RH4|1
A5|4RH5|10305RH5|1
A5|4RH1|10305RH1|1
A5|4RH1|10305RH1|1
A5|4RA1|10305RA1|1
A5|4RH1|10305RH1|1
A5|4RO1|10305RO1|1
A3|XXX|XXX|1
A2|XXX|XXX|1
A5|4RH1|10305RH1|1
;;;;
&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;You can make a new true/false (1/0) variable by running code like:&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data want ;
  set forum;
  new_var = (A='XXX' and B='XXX');
run;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;You can shorten the test this way:&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;  new_var = (A=B='XXX');&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Tue, 05 Jan 2021 18:03:48 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Format-problem/m-p/709467#M218173</guid>
      <dc:creator>Tom</dc:creator>
      <dc:date>2021-01-05T18:03:48Z</dc:date>
    </item>
  </channel>
</rss>

