<?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: using index to create a new variable in New SAS User</title>
    <link>https://communities.sas.com/t5/New-SAS-User/using-index-to-create-a-new-variable/m-p/735940#M28699</link>
    <description>&lt;P&gt;Hello&amp;nbsp;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/355559"&gt;@epidemiologystu&lt;/a&gt;,&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;There are two issues:&lt;/P&gt;
&lt;OL&gt;
&lt;LI&gt;The INDEX function is case-sensitive so that "breast" isn't found in "Breast NOS." Use the &lt;A href="https://documentation.sas.com/doc/en/pgmsascdc/9.4_3.5/lefunctionsref/p00ab6ey29t2i8n1ihel88tqtga9.htm" target="_blank" rel="noopener"&gt;FIND function&lt;/A&gt; with the 'i' modifier instead:&lt;BR /&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;find(curr_topog_desc, "breast", 'i')&lt;/CODE&gt;&lt;/PRE&gt;
or apply the LOWCASE function to the first argument:&lt;BR /&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;index(lowcase(curr_topog_desc), "breast")&lt;/CODE&gt;&lt;/PRE&gt;
&lt;/LI&gt;
&lt;LI&gt;Without an ELSE before the second IF the values assigned in the first THEN branch are overwritten by the last ELSE DO/END block.&lt;/LI&gt;
&lt;/OL&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;BLOCKQUOTE&gt;&lt;HR /&gt;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/355559"&gt;@epidemiologystu&lt;/a&gt;&amp;nbsp;wrote:&lt;BR /&gt;
&lt;P&gt;data sample ;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&amp;nbsp;input curr_topog_desc $30. ;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&amp;nbsp;cards ;&lt;/P&gt;
&lt;P&gt;Rectum NOS&lt;/P&gt;
&lt;P&gt;Overlapping lesion of breast&lt;/P&gt;
&lt;P&gt;Head of pancreas&lt;/P&gt;
&lt;P&gt;Blood&lt;/P&gt;
&lt;P&gt;Breast NOS&lt;/P&gt;
&lt;P&gt;" " *meant to be blank;&lt;/P&gt;
&lt;HR /&gt;&lt;/BLOCKQUOTE&gt;
&lt;P&gt;Use a single period (.) to enter a missing value in data lines, not a blank in double quotes.&lt;/P&gt;</description>
    <pubDate>Wed, 21 Apr 2021 12:42:03 GMT</pubDate>
    <dc:creator>FreelanceReinh</dc:creator>
    <dc:date>2021-04-21T12:42:03Z</dc:date>
    <item>
      <title>using index to create a new variable</title>
      <link>https://communities.sas.com/t5/New-SAS-User/using-index-to-create-a-new-variable/m-p/735924#M28698</link>
      <description>&lt;P&gt;Hello,&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;This piece of code is not correctly assigning all breast cancer cases. Could someone identify the error?&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;*create sample dataset;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;data sample ;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;input curr_topog_desc $30. ;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;cards ;&lt;/P&gt;&lt;P&gt;Rectum NOS&lt;/P&gt;&lt;P&gt;Overlapping lesion of breast&lt;/P&gt;&lt;P&gt;Head of pancreas&lt;/P&gt;&lt;P&gt;Blood&lt;/P&gt;&lt;P&gt;Breast NOS&lt;/P&gt;&lt;P&gt;" " *meant to be blank;&lt;/P&gt;&lt;P&gt;;&lt;/P&gt;&lt;P&gt;run;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Data sample;&lt;/P&gt;&lt;P&gt;Set sample;&lt;/P&gt;&lt;P&gt;IF index(curr_topog_desc, "breast") ne 0 then do;&lt;/P&gt;&lt;P&gt;breastcancer = 1;&lt;/P&gt;&lt;P&gt;othercancer = 0;&lt;/P&gt;&lt;P&gt;end;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;*if blank space, the person was not linked to cancer registry;&lt;/P&gt;&lt;P&gt;IF curr_topog_desc = " " THEN do;&lt;/P&gt;&lt;P&gt;breastcancer = 0;&lt;/P&gt;&lt;P&gt;othercancer = 0;&lt;/P&gt;&lt;P&gt;end;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;*meant to capture all other cancers;&lt;/P&gt;&lt;P&gt;ELSE do;&lt;/P&gt;&lt;P&gt;breastcancer = 0;&lt;/P&gt;&lt;P&gt;othercancer = 1;&lt;/P&gt;&lt;P&gt;end;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;run;&lt;/P&gt;</description>
      <pubDate>Wed, 21 Apr 2021 12:05:45 GMT</pubDate>
      <guid>https://communities.sas.com/t5/New-SAS-User/using-index-to-create-a-new-variable/m-p/735924#M28698</guid>
      <dc:creator>epidemiologystu</dc:creator>
      <dc:date>2021-04-21T12:05:45Z</dc:date>
    </item>
    <item>
      <title>Re: using index to create a new variable</title>
      <link>https://communities.sas.com/t5/New-SAS-User/using-index-to-create-a-new-variable/m-p/735940#M28699</link>
      <description>&lt;P&gt;Hello&amp;nbsp;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/355559"&gt;@epidemiologystu&lt;/a&gt;,&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;There are two issues:&lt;/P&gt;
&lt;OL&gt;
&lt;LI&gt;The INDEX function is case-sensitive so that "breast" isn't found in "Breast NOS." Use the &lt;A href="https://documentation.sas.com/doc/en/pgmsascdc/9.4_3.5/lefunctionsref/p00ab6ey29t2i8n1ihel88tqtga9.htm" target="_blank" rel="noopener"&gt;FIND function&lt;/A&gt; with the 'i' modifier instead:&lt;BR /&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;find(curr_topog_desc, "breast", 'i')&lt;/CODE&gt;&lt;/PRE&gt;
or apply the LOWCASE function to the first argument:&lt;BR /&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;index(lowcase(curr_topog_desc), "breast")&lt;/CODE&gt;&lt;/PRE&gt;
&lt;/LI&gt;
&lt;LI&gt;Without an ELSE before the second IF the values assigned in the first THEN branch are overwritten by the last ELSE DO/END block.&lt;/LI&gt;
&lt;/OL&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;BLOCKQUOTE&gt;&lt;HR /&gt;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/355559"&gt;@epidemiologystu&lt;/a&gt;&amp;nbsp;wrote:&lt;BR /&gt;
&lt;P&gt;data sample ;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&amp;nbsp;input curr_topog_desc $30. ;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&amp;nbsp;cards ;&lt;/P&gt;
&lt;P&gt;Rectum NOS&lt;/P&gt;
&lt;P&gt;Overlapping lesion of breast&lt;/P&gt;
&lt;P&gt;Head of pancreas&lt;/P&gt;
&lt;P&gt;Blood&lt;/P&gt;
&lt;P&gt;Breast NOS&lt;/P&gt;
&lt;P&gt;" " *meant to be blank;&lt;/P&gt;
&lt;HR /&gt;&lt;/BLOCKQUOTE&gt;
&lt;P&gt;Use a single period (.) to enter a missing value in data lines, not a blank in double quotes.&lt;/P&gt;</description>
      <pubDate>Wed, 21 Apr 2021 12:42:03 GMT</pubDate>
      <guid>https://communities.sas.com/t5/New-SAS-User/using-index-to-create-a-new-variable/m-p/735940#M28699</guid>
      <dc:creator>FreelanceReinh</dc:creator>
      <dc:date>2021-04-21T12:42:03Z</dc:date>
    </item>
    <item>
      <title>Re: using index to create a new variable</title>
      <link>https://communities.sas.com/t5/New-SAS-User/using-index-to-create-a-new-variable/m-p/735969#M28703</link>
      <description>Thank you!!</description>
      <pubDate>Wed, 21 Apr 2021 13:55:23 GMT</pubDate>
      <guid>https://communities.sas.com/t5/New-SAS-User/using-index-to-create-a-new-variable/m-p/735969#M28703</guid>
      <dc:creator>epidemiologystu</dc:creator>
      <dc:date>2021-04-21T13:55:23Z</dc:date>
    </item>
  </channel>
</rss>

