<?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: How to create a new column based on values of an other column? in SAS Enterprise Guide</title>
    <link>https://communities.sas.com/t5/SAS-Enterprise-Guide/How-to-create-a-new-column-based-on-values-of-an-other-column/m-p/683937#M36986</link>
    <description>Thank you Tom. Short addition. What if Im looking for If contains 'blue'? for example there might be some values 'blueblack' or 'whiteblue'. I just need everything that contains blue to be marked with an ' * '. Hows that done?</description>
    <pubDate>Tue, 15 Sep 2020 12:11:29 GMT</pubDate>
    <dc:creator>AK100</dc:creator>
    <dc:date>2020-09-15T12:11:29Z</dc:date>
    <item>
      <title>How to create a new column based on values of an other column?</title>
      <link>https://communities.sas.com/t5/SAS-Enterprise-Guide/How-to-create-a-new-column-based-on-values-of-an-other-column/m-p/683924#M36984</link>
      <description>&lt;P&gt;I have a dataset called `my_dataset`. Now I want to create a new column (marked) that puts a * sign for every value in column color if that value is blue. What is the best way to do it?&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;This is my reproducible dataset.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;data my_dataset;
input customer $ ref color $20.;
datalines;
C1 101 red
C2 102 blue
C3 103 blue
C4 104 red
C5 105 yellow 
C6 106 blue 
;
run;&lt;/PRE&gt;
&lt;P&gt;This is my expected outcome:&lt;/P&gt;
&lt;P&gt;&lt;STRONG&gt;customer -- ref -- color -- marked&lt;/STRONG&gt;&lt;BR /&gt;C1&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; -- 101 --&amp;nbsp; red&amp;nbsp; &amp;nbsp; &amp;nbsp;--&amp;nbsp;&lt;BR /&gt;C2&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; -- 102 --&amp;nbsp; blue&amp;nbsp; &amp;nbsp; --&amp;nbsp; &amp;nbsp; *&lt;BR /&gt;C3&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; --&amp;nbsp; 103 --&amp;nbsp; blue&amp;nbsp; &amp;nbsp;--&amp;nbsp; &amp;nbsp;*&lt;BR /&gt;C4&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;-- 104&amp;nbsp; -- red&amp;nbsp; &amp;nbsp; &amp;nbsp;--&lt;BR /&gt;C5&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;--&amp;nbsp; &amp;nbsp;105 -- yellow&amp;nbsp; --&amp;nbsp;&lt;BR /&gt;C6&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; --&amp;nbsp; 106&amp;nbsp; --&amp;nbsp; blue&amp;nbsp; &amp;nbsp; --&amp;nbsp; *&lt;/P&gt;</description>
      <pubDate>Tue, 15 Sep 2020 11:27:48 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Enterprise-Guide/How-to-create-a-new-column-based-on-values-of-an-other-column/m-p/683924#M36984</guid>
      <dc:creator>AK100</dc:creator>
      <dc:date>2020-09-15T11:27:48Z</dc:date>
    </item>
    <item>
      <title>Re: How to create a new column based on values of an other column?</title>
      <link>https://communities.sas.com/t5/SAS-Enterprise-Guide/How-to-create-a-new-column-based-on-values-of-an-other-column/m-p/683935#M36985</link>
      <description>&lt;P&gt;A simple IF statement will let your conditionally assign values to your new variable.&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data want;
  set my_dataset;
  if color='blue' then marked='*';
run;&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Tue, 15 Sep 2020 11:50:34 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Enterprise-Guide/How-to-create-a-new-column-based-on-values-of-an-other-column/m-p/683935#M36985</guid>
      <dc:creator>Tom</dc:creator>
      <dc:date>2020-09-15T11:50:34Z</dc:date>
    </item>
    <item>
      <title>Re: How to create a new column based on values of an other column?</title>
      <link>https://communities.sas.com/t5/SAS-Enterprise-Guide/How-to-create-a-new-column-based-on-values-of-an-other-column/m-p/683937#M36986</link>
      <description>Thank you Tom. Short addition. What if Im looking for If contains 'blue'? for example there might be some values 'blueblack' or 'whiteblue'. I just need everything that contains blue to be marked with an ' * '. Hows that done?</description>
      <pubDate>Tue, 15 Sep 2020 12:11:29 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Enterprise-Guide/How-to-create-a-new-column-based-on-values-of-an-other-column/m-p/683937#M36986</guid>
      <dc:creator>AK100</dc:creator>
      <dc:date>2020-09-15T12:11:29Z</dc:date>
    </item>
    <item>
      <title>Re: How to create a new column based on values of an other column?</title>
      <link>https://communities.sas.com/t5/SAS-Enterprise-Guide/How-to-create-a-new-column-based-on-values-of-an-other-column/m-p/683938#M36987</link>
      <description>&lt;P&gt;Just change the condition you are using in the IF statement.&amp;nbsp; For example you could use the INDEX() function&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;if index(color,'blue') then .....&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;or the FIND() function or even one of the PRX.... functions that use regular expressions.&amp;nbsp; You might want to make the test case insensitive.&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;if index(lowcase(color),'blue') then .....&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Tue, 15 Sep 2020 12:21:26 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Enterprise-Guide/How-to-create-a-new-column-based-on-values-of-an-other-column/m-p/683938#M36987</guid>
      <dc:creator>Tom</dc:creator>
      <dc:date>2020-09-15T12:21:26Z</dc:date>
    </item>
    <item>
      <title>Re: How to create a new column based on values of an other column?</title>
      <link>https://communities.sas.com/t5/SAS-Enterprise-Guide/How-to-create-a-new-column-based-on-values-of-an-other-column/m-p/683948#M36988</link>
      <description>Thank you possible to add an else statement after then?</description>
      <pubDate>Tue, 15 Sep 2020 13:25:33 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Enterprise-Guide/How-to-create-a-new-column-based-on-values-of-an-other-column/m-p/683948#M36988</guid>
      <dc:creator>AK100</dc:creator>
      <dc:date>2020-09-15T13:25:33Z</dc:date>
    </item>
    <item>
      <title>Re: How to create a new column based on values of an other column?</title>
      <link>https://communities.sas.com/t5/SAS-Enterprise-Guide/How-to-create-a-new-column-based-on-values-of-an-other-column/m-p/683955#M36990</link>
      <description>Sure.  Check the documentation.  &lt;A href="https://documentation.sas.com/?docsetId=lestmtsref&amp;amp;docsetTarget=n1j60arf27ll4nn1ejavv3nby4pa.htm&amp;amp;docsetVersion=9.4&amp;amp;locale=en" target="_blank"&gt;https://documentation.sas.com/?docsetId=lestmtsref&amp;amp;docsetTarget=n1j60arf27ll4nn1ejavv3nby4pa.htm&amp;amp;docsetVersion=9.4&amp;amp;locale=en&lt;/A&gt;</description>
      <pubDate>Tue, 15 Sep 2020 14:00:43 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Enterprise-Guide/How-to-create-a-new-column-based-on-values-of-an-other-column/m-p/683955#M36990</guid>
      <dc:creator>Tom</dc:creator>
      <dc:date>2020-09-15T14:00:43Z</dc:date>
    </item>
    <item>
      <title>Re: How to create a new column based on values of an other column?</title>
      <link>https://communities.sas.com/t5/SAS-Enterprise-Guide/How-to-create-a-new-column-based-on-values-of-an-other-column/m-p/683965#M36991</link>
      <description>&lt;P&gt;What do those dashes mean in the "expected output"?&lt;/P&gt;</description>
      <pubDate>Tue, 15 Sep 2020 14:27:01 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Enterprise-Guide/How-to-create-a-new-column-based-on-values-of-an-other-column/m-p/683965#M36991</guid>
      <dc:creator>ballardw</dc:creator>
      <dc:date>2020-09-15T14:27:01Z</dc:date>
    </item>
  </channel>
</rss>

