<?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: Create dummy variables but have to use where clause in SAS Procedures</title>
    <link>https://communities.sas.com/t5/SAS-Procedures/Create-dummy-variables-but-have-to-use-where-clause/m-p/17775#M3417</link>
    <description>I will try find function and just figure out that probably I can use "isnumber" in excel.</description>
    <pubDate>Fri, 25 Feb 2011 20:28:08 GMT</pubDate>
    <dc:creator>deleted_user</dc:creator>
    <dc:date>2011-02-25T20:28:08Z</dc:date>
    <item>
      <title>Create dummy variables but have to use where clause</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/Create-dummy-variables-but-have-to-use-where-clause/m-p/17773#M3415</link>
      <description>Hi All,&lt;BR /&gt;
&lt;BR /&gt;
I have two columns of data with very noisy information in the second column.&lt;BR /&gt;
&lt;BR /&gt;
It looks like,&lt;BR /&gt;
&lt;BR /&gt;
Name    title&lt;BR /&gt;
A          ceo&amp;amp;chair&lt;BR /&gt;
A          Chief executive officer&lt;BR /&gt;
A          former ceo&lt;BR /&gt;
B          vp&lt;BR /&gt;
B          senior vp&lt;BR /&gt;
B          executive vp&lt;BR /&gt;
.........................................&lt;BR /&gt;
Z          cfo&lt;BR /&gt;
Z          chief finance officer&lt;BR /&gt;
Z          chairman&lt;BR /&gt;
&lt;BR /&gt;
I notice I can use "if then" to create dummies, but I need to apply "contains" at the same time to classify data. "contains" can be used only in WHERE statement (from what I read).&lt;BR /&gt;
&lt;BR /&gt;
my classification would be like,&lt;BR /&gt;
if title contains ' ceo' or title contains 'chief executive'  then _title=1;&lt;BR /&gt;
if title contains 'cfo' or title contains 'chief fiance' then _title=2;&lt;BR /&gt;
if title contains 'vice president' or title contains 'vp' then _title=3;&lt;BR /&gt;
if title contains 'chairman' or title contains 'chrm' then _title=4;&lt;BR /&gt;
then the rest wil be categorized as  _title=others;&lt;BR /&gt;
&lt;BR /&gt;
the outcome will look like based on my example,&lt;BR /&gt;
&lt;BR /&gt;
Name    title                                  _title&lt;BR /&gt;
A          ceo&amp;amp;chair                         1&lt;BR /&gt;
A          Chief executive officer        1&lt;BR /&gt;
A          former ceo                        1&lt;BR /&gt;
B          vp                                    3&lt;BR /&gt;
B          senior vp                          3&lt;BR /&gt;
B          executive vp                     3&lt;BR /&gt;
...........................................................&lt;BR /&gt;
Z          cfo                                   2&lt;BR /&gt;
Z          chief finance officer            2&lt;BR /&gt;
Z          chairman                          4&lt;BR /&gt;
&lt;BR /&gt;
So, my question, how can I create dummies but apply contain function at the same time?&lt;BR /&gt;
&lt;BR /&gt;
Thanks very much for sharing your views!</description>
      <pubDate>Fri, 25 Feb 2011 19:37:47 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/Create-dummy-variables-but-have-to-use-where-clause/m-p/17773#M3415</guid>
      <dc:creator>deleted_user</dc:creator>
      <dc:date>2011-02-25T19:37:47Z</dc:date>
    </item>
    <item>
      <title>Re: Create dummy variables but have to use where clause</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/Create-dummy-variables-but-have-to-use-where-clause/m-p/17774#M3416</link>
      <description>I think you can use the find function here.  &lt;BR /&gt;
&lt;BR /&gt;
You could change your conditional logic to be something like:&lt;BR /&gt;
&lt;BR /&gt;
if find(lowcase(title), "ceo") &amp;gt; 0 then _title = 1;&lt;BR /&gt;
else if find(lowcase(title),'cfo') &amp;gt; 0 or find(lowcase(title),'chief finance') &amp;gt; 0 then _title=2;&lt;BR /&gt;
&lt;BR /&gt;
&lt;BR /&gt;
SAS Documentation:  &lt;A href="http://support.sas.com/documentation/cdl/en/lrdict/64316/HTML/default/viewer.htm#a002267763.htm" target="_blank"&gt;http://support.sas.com/documentation/cdl/en/lrdict/64316/HTML/default/viewer.htm#a002267763.htm&lt;/A&gt;</description>
      <pubDate>Fri, 25 Feb 2011 20:19:50 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/Create-dummy-variables-but-have-to-use-where-clause/m-p/17774#M3416</guid>
      <dc:creator>Rambo</dc:creator>
      <dc:date>2011-02-25T20:19:50Z</dc:date>
    </item>
    <item>
      <title>Re: Create dummy variables but have to use where clause</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/Create-dummy-variables-but-have-to-use-where-clause/m-p/17775#M3417</link>
      <description>I will try find function and just figure out that probably I can use "isnumber" in excel.</description>
      <pubDate>Fri, 25 Feb 2011 20:28:08 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/Create-dummy-variables-but-have-to-use-where-clause/m-p/17775#M3417</guid>
      <dc:creator>deleted_user</dc:creator>
      <dc:date>2011-02-25T20:28:08Z</dc:date>
    </item>
    <item>
      <title>Re: Create dummy variables but have to use where clause</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/Create-dummy-variables-but-have-to-use-where-clause/m-p/17776#M3418</link>
      <description>hi ... building on the suggestion to use FIND, you can also try ..&lt;BR /&gt;
&lt;BR /&gt;
data x;&lt;BR /&gt;
input &lt;BR /&gt;
@1 group    $1.&lt;BR /&gt;
@3 title   $50.&lt;BR /&gt;
;&lt;BR /&gt;
datalines;&lt;BR /&gt;
A secretary&lt;BR /&gt;
A ceo&amp;amp;chair&lt;BR /&gt;
A Chief executive officer&lt;BR /&gt;
A former ceo&lt;BR /&gt;
B vp&lt;BR /&gt;
B senior vp&lt;BR /&gt;
B executive vp&lt;BR /&gt;
C CEO&lt;BR /&gt;
D VP&lt;BR /&gt;
Z cfo&lt;BR /&gt;
Z chief finance officer&lt;BR /&gt;
Z chairman&lt;BR /&gt;
Z janitor&lt;BR /&gt;
;&lt;BR /&gt;
run;&lt;BR /&gt;
&lt;BR /&gt;
data xplus;&lt;BR /&gt;
set x;&lt;BR /&gt;
t = lowcase(title);&lt;BR /&gt;
_title = (find(t,'ceo')  or find(t,'chief executive')) * 1 +&lt;BR /&gt;
         (find(t,'cfo')  or find(t,'chief finance'))   * 2 +&lt;BR /&gt;
         (find(t,'vp')   or find(t,'vice president'))  * 3 +&lt;BR /&gt;
         (find(t,'chrm') or find(t,'chairman'))        * 4;&lt;BR /&gt;
_title = ifn(_title eq 0,_title+5,_title);&lt;BR /&gt;
drop t;&lt;BR /&gt;
run;</description>
      <pubDate>Sat, 26 Feb 2011 03:36:05 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/Create-dummy-variables-but-have-to-use-where-clause/m-p/17776#M3418</guid>
      <dc:creator>MikeZdeb</dc:creator>
      <dc:date>2011-02-26T03:36:05Z</dc:date>
    </item>
  </channel>
</rss>

