<?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: Efficiently organizing multiple levels of a categorical variable into a single numeric variable in New SAS User</title>
    <link>https://communities.sas.com/t5/New-SAS-User/Efficiently-organizing-multiple-levels-of-a-categorical-variable/m-p/761404#M30325</link>
    <description>Make a mapping dataset like:&lt;BR /&gt;&lt;BR /&gt;Apple 1&lt;BR /&gt;apples 1&lt;BR /&gt;applle 1&lt;BR /&gt;.........&lt;BR /&gt;&lt;BR /&gt;and using Hash Table to solve it .</description>
    <pubDate>Fri, 13 Aug 2021 12:31:01 GMT</pubDate>
    <dc:creator>Ksharp</dc:creator>
    <dc:date>2021-08-13T12:31:01Z</dc:date>
    <item>
      <title>Efficiently organizing multiple levels of a categorical variable into a single numeric variable</title>
      <link>https://communities.sas.com/t5/New-SAS-User/Efficiently-organizing-multiple-levels-of-a-categorical-variable/m-p/761169#M30319</link>
      <description>&lt;P&gt;Hello,&amp;nbsp;&lt;/P&gt;&lt;P&gt;I have a long list of entries for a categorical variable classified into levels in a RTF document.&lt;/P&gt;&lt;P&gt;What is the most efficient way to reclassify each observation into a new numeric variable? There is a lot of variation in punctuation between apparently similar observations, which I've classified manually.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Sample code, which works, but is untenable for hundreds of individual iterations of each level...&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;data new;&lt;BR /&gt;set old;&lt;BR /&gt;length fruit_num 8.;&lt;BR /&gt;if fruit = 'Apple' or fruit = 'Apples' or fruit = 'apple' then fruit_num = 1;&lt;/P&gt;&lt;P&gt;if fruit = 'Orange' or fruit = 'Oranges' or fruit = ' organge' then fruit_num = 2;&lt;/P&gt;&lt;P&gt;else fruit_num = .;&lt;/P&gt;&lt;P&gt;run;&lt;/P&gt;</description>
      <pubDate>Thu, 12 Aug 2021 15:06:39 GMT</pubDate>
      <guid>https://communities.sas.com/t5/New-SAS-User/Efficiently-organizing-multiple-levels-of-a-categorical-variable/m-p/761169#M30319</guid>
      <dc:creator>EmilyAV</dc:creator>
      <dc:date>2021-08-12T15:06:39Z</dc:date>
    </item>
    <item>
      <title>Re: Efficiently organizing multiple levels of a categorical variable into a single numeric variable</title>
      <link>https://communities.sas.com/t5/New-SAS-User/Efficiently-organizing-multiple-levels-of-a-categorical-variable/m-p/761173#M30320</link>
      <description>Make your RTF file an Excel file with one column having the original value and the second column having the new value. &lt;BR /&gt;Then merge your two tables together. You can help yourself do some of this programatically by also standardizing the values in some manner - ie ensuring all are lower case, remove 's' at the end to at least get started. &lt;BR /&gt;&lt;BR /&gt;You can also use the IN operator:&lt;BR /&gt;&lt;BR /&gt;if upcase(fruit) in: ('APPLE') then fruit_num=1;&lt;BR /&gt;&lt;BR /&gt;Anything that starts with APPLE (regardless of case) will now get classified as fruit_num=1, even APPLEPIE. Note the colon and IN usage in that statement. &lt;BR /&gt;It will not capture lines like Organge though. &lt;BR /&gt;</description>
      <pubDate>Thu, 12 Aug 2021 15:30:13 GMT</pubDate>
      <guid>https://communities.sas.com/t5/New-SAS-User/Efficiently-organizing-multiple-levels-of-a-categorical-variable/m-p/761173#M30320</guid>
      <dc:creator>Reeza</dc:creator>
      <dc:date>2021-08-12T15:30:13Z</dc:date>
    </item>
    <item>
      <title>Re: Efficiently organizing multiple levels of a categorical variable into a single numeric variable</title>
      <link>https://communities.sas.com/t5/New-SAS-User/Efficiently-organizing-multiple-levels-of-a-categorical-variable/m-p/761404#M30325</link>
      <description>Make a mapping dataset like:&lt;BR /&gt;&lt;BR /&gt;Apple 1&lt;BR /&gt;apples 1&lt;BR /&gt;applle 1&lt;BR /&gt;.........&lt;BR /&gt;&lt;BR /&gt;and using Hash Table to solve it .</description>
      <pubDate>Fri, 13 Aug 2021 12:31:01 GMT</pubDate>
      <guid>https://communities.sas.com/t5/New-SAS-User/Efficiently-organizing-multiple-levels-of-a-categorical-variable/m-p/761404#M30325</guid>
      <dc:creator>Ksharp</dc:creator>
      <dc:date>2021-08-13T12:31:01Z</dc:date>
    </item>
    <item>
      <title>Re: Efficiently organizing multiple levels of a categorical variable into a single numeric variable</title>
      <link>https://communities.sas.com/t5/New-SAS-User/Efficiently-organizing-multiple-levels-of-a-categorical-variable/m-p/761775#M30335</link>
      <description>&lt;P&gt;Works great, thank you!&lt;/P&gt;</description>
      <pubDate>Mon, 16 Aug 2021 12:05:24 GMT</pubDate>
      <guid>https://communities.sas.com/t5/New-SAS-User/Efficiently-organizing-multiple-levels-of-a-categorical-variable/m-p/761775#M30335</guid>
      <dc:creator>EmilyAV</dc:creator>
      <dc:date>2021-08-16T12:05:24Z</dc:date>
    </item>
  </channel>
</rss>

