<?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: SAS EG Computing new column with advanced expression while using FIND function in SAS Enterprise Guide</title>
    <link>https://communities.sas.com/t5/SAS-Enterprise-Guide/SAS-EG-Computing-new-column-with-advanced-expression-while-using/m-p/664652#M36280</link>
    <description>&lt;P&gt;See this data step code:&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data have;
input project :$3. department :$3.;
datalines;
PRQ AAA
XYZ BBB
;

data want;
set have;
if find(project,'XYZ') then department = 'ABC';
run;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;With SQL, it looks like this:&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;proc sql;
create table want as
  select
    project,
    case
      when find(project,'XYZ') then 'ABC'
      else department
    end as department
  from have
;
quit;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;If you need to create an expression in EG's Query Builder, you need to use SQL syntax (case-when-then-else-end)&lt;/P&gt;</description>
    <pubDate>Wed, 24 Jun 2020 14:51:38 GMT</pubDate>
    <dc:creator>Kurt_Bremser</dc:creator>
    <dc:date>2020-06-24T14:51:38Z</dc:date>
    <item>
      <title>SAS EG Computing new column with advanced expression while using FIND function</title>
      <link>https://communities.sas.com/t5/SAS-Enterprise-Guide/SAS-EG-Computing-new-column-with-advanced-expression-while-using/m-p/664634#M36277</link>
      <description>&lt;P&gt;Hi Everyone,&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Currently I am working in SAS Enterprise Guide. I'm trying to create a new column from two columns using advanced expression. The idea is this: There is a column named 'Department' and one named 'Project'. If in 'Project' the characters contain 'XYZ', then the value in 'Department' needs to be adjusted to 'ABC'. If, in 'Project' the characters do not contain 'XYZ', we need to keep using the value already present in 'Department'. So basically I'm trying to replace a value in 'Department', based on the values in 'Project'. I'm trying to use FIND within a IF ELSE statement, but so far it's not working. Searches online are not really helping.&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Does anyone have a suggestion as to how I can achieve this result? Many thanks!&lt;/P&gt;</description>
      <pubDate>Wed, 24 Jun 2020 13:37:05 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Enterprise-Guide/SAS-EG-Computing-new-column-with-advanced-expression-while-using/m-p/664634#M36277</guid>
      <dc:creator>Margot89</dc:creator>
      <dc:date>2020-06-24T13:37:05Z</dc:date>
    </item>
    <item>
      <title>Re: SAS EG Computing new column with advanced expression while using FIND function</title>
      <link>https://communities.sas.com/t5/SAS-Enterprise-Guide/SAS-EG-Computing-new-column-with-advanced-expression-while-using/m-p/664650#M36279</link>
      <description>&lt;P&gt;Not having the data you're working with, I made some up. Give this a try:&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data have;
    input department $ project &amp;amp; $15.;
    datalines;
    dept_1  QWERTY
    dept_2  WXYZ
    dept_3  123-XYZ
    dept_4  not capital xyz
    ;
run;

data want;
    set have;
    if find(project, 'XYZ') ge 1
        then department = 'ABC';
run;&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Wed, 24 Jun 2020 14:48:34 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Enterprise-Guide/SAS-EG-Computing-new-column-with-advanced-expression-while-using/m-p/664650#M36279</guid>
      <dc:creator>mklangley</dc:creator>
      <dc:date>2020-06-24T14:48:34Z</dc:date>
    </item>
    <item>
      <title>Re: SAS EG Computing new column with advanced expression while using FIND function</title>
      <link>https://communities.sas.com/t5/SAS-Enterprise-Guide/SAS-EG-Computing-new-column-with-advanced-expression-while-using/m-p/664652#M36280</link>
      <description>&lt;P&gt;See this data step code:&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data have;
input project :$3. department :$3.;
datalines;
PRQ AAA
XYZ BBB
;

data want;
set have;
if find(project,'XYZ') then department = 'ABC';
run;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;With SQL, it looks like this:&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;proc sql;
create table want as
  select
    project,
    case
      when find(project,'XYZ') then 'ABC'
      else department
    end as department
  from have
;
quit;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;If you need to create an expression in EG's Query Builder, you need to use SQL syntax (case-when-then-else-end)&lt;/P&gt;</description>
      <pubDate>Wed, 24 Jun 2020 14:51:38 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Enterprise-Guide/SAS-EG-Computing-new-column-with-advanced-expression-while-using/m-p/664652#M36280</guid>
      <dc:creator>Kurt_Bremser</dc:creator>
      <dc:date>2020-06-24T14:51:38Z</dc:date>
    </item>
    <item>
      <title>Re: SAS EG Computing new column with advanced expression while using FIND function</title>
      <link>https://communities.sas.com/t5/SAS-Enterprise-Guide/SAS-EG-Computing-new-column-with-advanced-expression-while-using/m-p/664822#M36295</link>
      <description>&lt;P&gt;After selecting &lt;STRONG&gt;Advanced Expression&lt;/STRONG&gt; click Next then type this into the &lt;EM&gt;Enter an Expression&lt;/EM&gt; box&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;case when find(project,'XYZ') ne 0 then 'ABC' else Department end&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Thu, 25 Jun 2020 01:24:12 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Enterprise-Guide/SAS-EG-Computing-new-column-with-advanced-expression-while-using/m-p/664822#M36295</guid>
      <dc:creator>sustagens</dc:creator>
      <dc:date>2020-06-25T01:24:12Z</dc:date>
    </item>
    <item>
      <title>Re: SAS EG Computing new column with advanced expression while using FIND function</title>
      <link>https://communities.sas.com/t5/SAS-Enterprise-Guide/SAS-EG-Computing-new-column-with-advanced-expression-while-using/m-p/664934#M36297</link>
      <description>&lt;P&gt;Thanks, this turned out to be the proper solution!&lt;/P&gt;</description>
      <pubDate>Thu, 25 Jun 2020 09:54:52 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Enterprise-Guide/SAS-EG-Computing-new-column-with-advanced-expression-while-using/m-p/664934#M36297</guid>
      <dc:creator>Margot89</dc:creator>
      <dc:date>2020-06-25T09:54:52Z</dc:date>
    </item>
  </channel>
</rss>

