<?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: Creating a 4th variable based on information from 3 variables in SAS Procedures</title>
    <link>https://communities.sas.com/t5/SAS-Procedures/Creating-a-4th-variable-based-on-information-from-3-variables/m-p/144406#M38384</link>
    <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hi,&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Above suggested solutions are based on your sample data. Provide a sample data that reflects the current scenario.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
    <pubDate>Thu, 11 Dec 2014 05:56:12 GMT</pubDate>
    <dc:creator>stat_sas</dc:creator>
    <dc:date>2014-12-11T05:56:12Z</dc:date>
    <item>
      <title>Creating a 4th variable based on information from 3 variables</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/Creating-a-4th-variable-based-on-information-from-3-variables/m-p/144402#M38380</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;I have a dataset like this:&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;ID product&amp;nbsp; DESC&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; product2&lt;/P&gt;&lt;P&gt;1&amp;nbsp;&amp;nbsp; A&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; A/B-Q&amp;nbsp;&amp;nbsp; A&lt;/P&gt;&lt;P&gt;1&amp;nbsp;&amp;nbsp; A&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; A/B-Q&amp;nbsp;&amp;nbsp; B&lt;/P&gt;&lt;P&gt;2&amp;nbsp;&amp;nbsp; A&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; XYZ&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; A&lt;/P&gt;&lt;P&gt;2&amp;nbsp;&amp;nbsp; A&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; XYZ&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; B&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;I want to create the variable product3, such that it looks the product2 in variable "desc" and if its found then product3=product2 else product3=product. So product 3 will be:&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Product3&lt;/P&gt;&lt;P&gt;A&lt;/P&gt;&lt;P&gt;B&lt;/P&gt;&lt;P&gt;A&lt;/P&gt;&lt;P&gt;A&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Wed, 10 Dec 2014 14:06:19 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/Creating-a-4th-variable-based-on-information-from-3-variables/m-p/144402#M38380</guid>
      <dc:creator>munitech4u</dc:creator>
      <dc:date>2014-12-10T14:06:19Z</dc:date>
    </item>
    <item>
      <title>Re: Creating a 4th variable based on information from 3 variables</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/Creating-a-4th-variable-based-on-information-from-3-variables/m-p/144403#M38381</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;data want;&lt;/P&gt;&lt;P&gt;set have;&lt;/P&gt;&lt;P&gt;if findc(strip(desc),strip(product2)) then product3=product2;&lt;/P&gt;&lt;P&gt;else product3=product;&lt;/P&gt;&lt;P&gt;run;&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Wed, 10 Dec 2014 14:16:51 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/Creating-a-4th-variable-based-on-information-from-3-variables/m-p/144403#M38381</guid>
      <dc:creator>stat_sas</dc:creator>
      <dc:date>2014-12-10T14:16:51Z</dc:date>
    </item>
    <item>
      <title>Re: Creating a 4th variable based on information from 3 variables</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/Creating-a-4th-variable-based-on-information-from-3-variables/m-p/144404#M38382</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Maybe proc sql:&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Proc SQL;&lt;/P&gt;&lt;P&gt;&amp;nbsp; Create Table Want As&lt;/P&gt;&lt;P&gt;&amp;nbsp; Select *, &lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; Case When Index(Desc,Strip(product2)) Then product2 Else product End As product3&lt;/P&gt;&lt;P&gt;&amp;nbsp; From Have;&lt;/P&gt;&lt;P&gt;Quit;&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Wed, 10 Dec 2014 14:42:48 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/Creating-a-4th-variable-based-on-information-from-3-variables/m-p/144404#M38382</guid>
      <dc:creator>user24feb</dc:creator>
      <dc:date>2014-12-10T14:42:48Z</dc:date>
    </item>
    <item>
      <title>Re: Creating a 4th variable based on information from 3 variables</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/Creating-a-4th-variable-based-on-information-from-3-variables/m-p/144405#M38383</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Thank you,but this doesnt seem to be working in conditions where like i have product2 as say "Aol" and desc as "Kypro 60 MG". as product2 is not found n desc, the product3 should be equal to product.Also is it possible to look for only first 3 chars from the product2 in desc?&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Thu, 11 Dec 2014 05:14:30 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/Creating-a-4th-variable-based-on-information-from-3-variables/m-p/144405#M38383</guid>
      <dc:creator>munitech4u</dc:creator>
      <dc:date>2014-12-11T05:14:30Z</dc:date>
    </item>
    <item>
      <title>Re: Creating a 4th variable based on information from 3 variables</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/Creating-a-4th-variable-based-on-information-from-3-variables/m-p/144406#M38384</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hi,&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Above suggested solutions are based on your sample data. Provide a sample data that reflects the current scenario.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Thu, 11 Dec 2014 05:56:12 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/Creating-a-4th-variable-based-on-information-from-3-variables/m-p/144406#M38384</guid>
      <dc:creator>stat_sas</dc:creator>
      <dc:date>2014-12-11T05:56:12Z</dc:date>
    </item>
    <item>
      <title>Re: Creating a 4th variable based on information from 3 variables</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/Creating-a-4th-variable-based-on-information-from-3-variables/m-p/144407#M38385</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;ID product&amp;nbsp; DESC&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; product2&lt;/P&gt;&lt;P&gt;1&amp;nbsp;&amp;nbsp; A&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; A/B-Q&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; A&lt;/P&gt;&lt;P&gt;1&amp;nbsp;&amp;nbsp; A&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; A/B-Q&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; B&lt;/P&gt;&lt;P&gt;2&amp;nbsp;&amp;nbsp; A&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; XYZ&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; A&lt;/P&gt;&lt;P&gt;2&amp;nbsp;&amp;nbsp; A&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; XYZ&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; B&lt;/P&gt;&lt;P&gt;3&amp;nbsp;&amp;nbsp; AOL&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; TYF NA&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; All other&lt;/P&gt;&lt;P&gt;3&amp;nbsp;&amp;nbsp; PED&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; PEDTRI/ORIG-TIM/QUOTE&amp;nbsp; PED&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Output:&lt;/P&gt;&lt;P&gt;Product3&lt;/P&gt;&lt;P&gt;A&lt;/P&gt;&lt;P&gt;B&lt;/P&gt;&lt;P&gt;A&lt;/P&gt;&lt;P&gt;A&lt;/P&gt;&lt;P&gt;AOL&lt;/P&gt;&lt;P&gt;PED&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;I think this covers most of the cases that I have in data&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Thu, 11 Dec 2014 06:03:07 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/Creating-a-4th-variable-based-on-information-from-3-variables/m-p/144407#M38385</guid>
      <dc:creator>munitech4u</dc:creator>
      <dc:date>2014-12-11T06:03:07Z</dc:date>
    </item>
    <item>
      <title>Re: Creating a 4th variable based on information from 3 variables</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/Creating-a-4th-variable-based-on-information-from-3-variables/m-p/144408#M38386</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hi&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Use the function Find in the above code instead of Findc&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;data want;&lt;/P&gt;&lt;P&gt;set have;&lt;/P&gt;&lt;P&gt;if find(strip(desc),strip(product2)) then product3=product2;&lt;/P&gt;&lt;P&gt;else product3=product;&lt;/P&gt;&lt;P&gt;run;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;FINDC will look for a character whereas FIND will look for the occurrence of a&amp;nbsp; string.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Thanks&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Thu, 11 Dec 2014 06:25:17 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/Creating-a-4th-variable-based-on-information-from-3-variables/m-p/144408#M38386</guid>
      <dc:creator>Karthikeyan</dc:creator>
      <dc:date>2014-12-11T06:25:17Z</dc:date>
    </item>
    <item>
      <title>Re: Creating a 4th variable based on information from 3 variables</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/Creating-a-4th-variable-based-on-information-from-3-variables/m-p/144409#M38387</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;FIND is not returning correct result. Its returning for first 2 product3 as A,A. I want it A,B&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Thu, 11 Dec 2014 07:57:24 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/Creating-a-4th-variable-based-on-information-from-3-variables/m-p/144409#M38387</guid>
      <dc:creator>munitech4u</dc:creator>
      <dc:date>2014-12-11T07:57:24Z</dc:date>
    </item>
    <item>
      <title>Re: Creating a 4th variable based on information from 3 variables</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/Creating-a-4th-variable-based-on-information-from-3-variables/m-p/144410#M38388</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hi&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;I ran this code &lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;data&lt;/P&gt;&lt;P&gt;have&lt;/P&gt;&lt;P&gt;;&lt;/P&gt;&lt;P&gt;input id product $ desc : $25. product2 $ ;&lt;/P&gt;&lt;P&gt;datalines;&lt;/P&gt;&lt;P&gt;1&amp;nbsp;&amp;nbsp; A&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; A/B-Q&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; A&lt;/P&gt;&lt;P&gt;1&amp;nbsp;&amp;nbsp; A&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; A/B-Q&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; B&lt;/P&gt;&lt;P&gt;2&amp;nbsp;&amp;nbsp; A&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; XYZ&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; A&lt;/P&gt;&lt;P&gt;2&amp;nbsp;&amp;nbsp; A&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; XYZ&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; B&lt;/P&gt;&lt;P&gt;3&amp;nbsp;&amp;nbsp; AOL&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; TYF NA&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; All other&lt;/P&gt;&lt;P&gt;3&amp;nbsp;&amp;nbsp; PED&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; PEDTRI/ORIG-TIM/QUOTE&amp;nbsp; PED&lt;/P&gt;&lt;P&gt;;&lt;/P&gt;&lt;P&gt;run;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;data want;&lt;/P&gt;&lt;P&gt;set have;&lt;/P&gt;&lt;P&gt;if find(strip(desc),strip(product2)) then product3=product2;&lt;/P&gt;&lt;P&gt;else product3=product;&lt;/P&gt;&lt;P&gt;run;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;proc print data = want;run;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;and this is the output I got&lt;/P&gt;&lt;P&gt;&lt;IMG alt="Capture.PNG" class="jive-image-thumbnail jive-image" height="221" src="https://communities.sas.com/legacyfs/online/8345_Capture.PNG" style="height: 221px; width: 450px;" width="450" /&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Thanks&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Thu, 11 Dec 2014 08:18:20 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/Creating-a-4th-variable-based-on-information-from-3-variables/m-p/144410#M38388</guid>
      <dc:creator>Karthikeyan</dc:creator>
      <dc:date>2014-12-11T08:18:20Z</dc:date>
    </item>
    <item>
      <title>Re: Creating a 4th variable based on information from 3 variables</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/Creating-a-4th-variable-based-on-information-from-3-variables/m-p/144411#M38389</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hmm.. Actually thats not the exact data i have, i had tried to create sample data. For some reason its returning me results like A,A. But thanks for your help, i need to find out more.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Thu, 11 Dec 2014 08:42:18 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/Creating-a-4th-variable-based-on-information-from-3-variables/m-p/144411#M38389</guid>
      <dc:creator>munitech4u</dc:creator>
      <dc:date>2014-12-11T08:42:18Z</dc:date>
    </item>
    <item>
      <title>Re: Creating a 4th variable based on information from 3 variables</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/Creating-a-4th-variable-based-on-information-from-3-variables/m-p/144412#M38390</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Just a thought: In contrast to index, find allows for modifiers, this is you can trim your variables and start at a certain position forwards or backwards: &lt;STRONG&gt;find(desc,product2,'t',-3)&lt;/STRONG&gt; should trim and starts backwards at position 3.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;BR /&gt; &lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Thu, 11 Dec 2014 08:52:14 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/Creating-a-4th-variable-based-on-information-from-3-variables/m-p/144412#M38390</guid>
      <dc:creator>user24feb</dc:creator>
      <dc:date>2014-12-11T08:52:14Z</dc:date>
    </item>
  </channel>
</rss>

