<?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 Index where if in SAS Procedures</title>
    <link>https://communities.sas.com/t5/SAS-Procedures/Index-where-if/m-p/8261#M328</link>
    <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;good idea art297!, it will remove the trailing blanks or leading blanks could contain this variable.&lt;/P&gt;&lt;P&gt;Thanks.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
    <pubDate>Tue, 21 Feb 2012 00:49:57 GMT</pubDate>
    <dc:creator>michtka</dc:creator>
    <dc:date>2012-02-21T00:49:57Z</dc:date>
    <item>
      <title>Index where if</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/Index-where-if/m-p/8256#M323</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hi to everyone,&lt;/P&gt;&lt;P&gt;When I try to make a dataset, I would like to filter a variable as:&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;data new;&lt;/P&gt;&lt;P&gt;set old;&lt;/P&gt;&lt;P&gt;if sex='F';&lt;/P&gt;&lt;P&gt;run;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;but, I dunno what happens, sometime sas dont read it properly, and i need to use:&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;if index(sex,'F')&amp;gt;0&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;and then it works.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Anyone can explain me why it happens with the first sentence, and why it works with the second one?&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Thanks.,&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;J.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Mon, 20 Feb 2012 23:54:39 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/Index-where-if/m-p/8256#M323</guid>
      <dc:creator>michtka</dc:creator>
      <dc:date>2012-02-20T23:54:39Z</dc:date>
    </item>
    <item>
      <title>Index where if</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/Index-where-if/m-p/8257#M324</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Because you probably have embedded spaces somewhere in the text, ie your text is actually, "&amp;nbsp; F" or "F&amp;nbsp; " &lt;/P&gt;&lt;P&gt;Hexadecimal also rings a bell..&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Mon, 20 Feb 2012 23:59:09 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/Index-where-if/m-p/8257#M324</guid>
      <dc:creator>Reeza</dc:creator>
      <dc:date>2012-02-20T23:59:09Z</dc:date>
    </item>
    <item>
      <title>Index where if</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/Index-where-if/m-p/8258#M325</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Sex either has leading spaces or some other character in there in addition to the letter F.&amp;nbsp; So when you scan for the letter F it matches, but the value is not just the letter 'F' .&amp;nbsp; Values could be ' F' or 'Female'.&amp;nbsp; You might have a tab or carriage return character in there.&amp;nbsp; You also might want to use UPCASE function to find the one's with lowercase f.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;IF INDEX(UPCASE(SEX),'F') ;&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Tue, 21 Feb 2012 00:32:15 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/Index-where-if/m-p/8258#M325</guid>
      <dc:creator>Tom</dc:creator>
      <dc:date>2012-02-21T00:32:15Z</dc:date>
    </item>
    <item>
      <title>Index where if</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/Index-where-if/m-p/8259#M326</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;You could also try:&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P style="background-color: #eef4f9;"&gt;data new;&lt;/P&gt;&lt;P style="background-color: #eef4f9;"&gt;set old;&lt;/P&gt;&lt;P style="background-color: #eef4f9;"&gt;if strip(upcase(sex))='F';&lt;/P&gt;&lt;P style="background-color: #eef4f9;"&gt;run;&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Tue, 21 Feb 2012 00:36:07 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/Index-where-if/m-p/8259#M326</guid>
      <dc:creator>art297</dc:creator>
      <dc:date>2012-02-21T00:36:07Z</dc:date>
    </item>
    <item>
      <title>Index where if</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/Index-where-if/m-p/8260#M327</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Thanks. I understand it, but there are some way to know how many trailing blanks contains this variable?...or always you recommend index(upcase(sex),'F')&lt;/P&gt;&lt;P&gt;to avoid this problem?&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Tue, 21 Feb 2012 00:47:33 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/Index-where-if/m-p/8260#M327</guid>
      <dc:creator>michtka</dc:creator>
      <dc:date>2012-02-21T00:47:33Z</dc:date>
    </item>
    <item>
      <title>Index where if</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/Index-where-if/m-p/8261#M328</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;good idea art297!, it will remove the trailing blanks or leading blanks could contain this variable.&lt;/P&gt;&lt;P&gt;Thanks.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Tue, 21 Feb 2012 00:49:57 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/Index-where-if/m-p/8261#M328</guid>
      <dc:creator>michtka</dc:creator>
      <dc:date>2012-02-21T00:49:57Z</dc:date>
    </item>
    <item>
      <title>Index where if</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/Index-where-if/m-p/8262#M329</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Trailing blanks are NOT the problem.&amp;nbsp; SAS stores all character variables as fixed length strings. It pads the string with blanks to fill.&amp;nbsp; If when you print the value it looks like F, but the test sex='F' does not work then the variable either contains a leading spaces or some other non-printable character.&amp;nbsp; Print it with the $HEX format to see the character codes.&lt;/P&gt;&lt;P&gt;Values less than '20'x (space) or greater than '7F' (tilda) are probably what is causeing your problem.&amp;nbsp; &lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;24&amp;nbsp;&amp;nbsp; data _null_;&lt;/P&gt;&lt;P&gt;25&amp;nbsp;&amp;nbsp;&amp;nbsp; length sex $5;&lt;/P&gt;&lt;P&gt;26&amp;nbsp;&amp;nbsp;&amp;nbsp; do sex = 'F',' F','F&amp;nbsp; ';&lt;/P&gt;&lt;P&gt;27&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; put sex= ' ' sex $hex.;&lt;/P&gt;&lt;P&gt;28&amp;nbsp;&amp;nbsp;&amp;nbsp; end;&lt;/P&gt;&lt;P&gt;29&amp;nbsp;&amp;nbsp; run;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;sex=F&amp;nbsp; 4620202020&lt;/P&gt;&lt;P&gt;sex=F&amp;nbsp; 2046202020&lt;/P&gt;&lt;P&gt;sex=F&amp;nbsp; 4620202020&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Tue, 21 Feb 2012 00:56:49 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/Index-where-if/m-p/8262#M329</guid>
      <dc:creator>Tom</dc:creator>
      <dc:date>2012-02-21T00:56:49Z</dc:date>
    </item>
  </channel>
</rss>

