<?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 Add Column Based on a logic in New SAS User</title>
    <link>https://communities.sas.com/t5/New-SAS-User/Add-Column-Based-on-a-logic/m-p/852760#M37488</link>
    <description>&lt;P&gt;I was working on a data where a table has 3 columns in which some of the column values are missing for example:&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="Kirito1_0-1673262910778.png" style="width: 400px;"&gt;&lt;img src="https://communities.sas.com/t5/image/serverpage/image-id/79170iA3A78A8D5542A48C/image-size/medium?v=v2&amp;amp;px=400" role="button" title="Kirito1_0-1673262910778.png" alt="Kirito1_0-1673262910778.png" /&gt;&lt;/span&gt;&lt;/P&gt;&lt;P&gt;Now, I want to achieve something like this. Where LC_CODE is not provided we pick from LG_CODE and if LG_CODE is not provided we pick from referral code. And if we don't have any values for any of the columns we just leave it as blank.&lt;/P&gt;&lt;P&gt;So the desired output should be something like this as below&lt;/P&gt;&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="Kirito1_1-1673263063343.png" style="width: 400px;"&gt;&lt;img src="https://communities.sas.com/t5/image/serverpage/image-id/79171i039BFC3C2A27F707/image-size/medium?v=v2&amp;amp;px=400" role="button" title="Kirito1_1-1673263063343.png" alt="Kirito1_1-1673263063343.png" /&gt;&lt;/span&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Something LIKE this&amp;nbsp;&lt;/P&gt;&lt;PRE&gt;&lt;CODE class=""&gt;Data FIN_EMP_CODE;
set MR7;
FIN_EMP_CODE = ;
if('LC Code'.MR7 NE . then 'LC Code'N = FIN_EMP_CODE);
else if ('LG Code'.MR7 NE . then 'LG Code'N = FIN_EMP_CODE);
else ('Referal Code'N.MR7 NE . then 'Referal Code'N = FIN_EMP_CODE);
run;&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;Can someone suggest what should I do to achieve this. Please, HELP!!!&lt;/P&gt;</description>
    <pubDate>Mon, 09 Jan 2023 11:29:35 GMT</pubDate>
    <dc:creator>Kirito1</dc:creator>
    <dc:date>2023-01-09T11:29:35Z</dc:date>
    <item>
      <title>Add Column Based on a logic</title>
      <link>https://communities.sas.com/t5/New-SAS-User/Add-Column-Based-on-a-logic/m-p/852760#M37488</link>
      <description>&lt;P&gt;I was working on a data where a table has 3 columns in which some of the column values are missing for example:&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="Kirito1_0-1673262910778.png" style="width: 400px;"&gt;&lt;img src="https://communities.sas.com/t5/image/serverpage/image-id/79170iA3A78A8D5542A48C/image-size/medium?v=v2&amp;amp;px=400" role="button" title="Kirito1_0-1673262910778.png" alt="Kirito1_0-1673262910778.png" /&gt;&lt;/span&gt;&lt;/P&gt;&lt;P&gt;Now, I want to achieve something like this. Where LC_CODE is not provided we pick from LG_CODE and if LG_CODE is not provided we pick from referral code. And if we don't have any values for any of the columns we just leave it as blank.&lt;/P&gt;&lt;P&gt;So the desired output should be something like this as below&lt;/P&gt;&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="Kirito1_1-1673263063343.png" style="width: 400px;"&gt;&lt;img src="https://communities.sas.com/t5/image/serverpage/image-id/79171i039BFC3C2A27F707/image-size/medium?v=v2&amp;amp;px=400" role="button" title="Kirito1_1-1673263063343.png" alt="Kirito1_1-1673263063343.png" /&gt;&lt;/span&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Something LIKE this&amp;nbsp;&lt;/P&gt;&lt;PRE&gt;&lt;CODE class=""&gt;Data FIN_EMP_CODE;
set MR7;
FIN_EMP_CODE = ;
if('LC Code'.MR7 NE . then 'LC Code'N = FIN_EMP_CODE);
else if ('LG Code'.MR7 NE . then 'LG Code'N = FIN_EMP_CODE);
else ('Referal Code'N.MR7 NE . then 'Referal Code'N = FIN_EMP_CODE);
run;&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;Can someone suggest what should I do to achieve this. Please, HELP!!!&lt;/P&gt;</description>
      <pubDate>Mon, 09 Jan 2023 11:29:35 GMT</pubDate>
      <guid>https://communities.sas.com/t5/New-SAS-User/Add-Column-Based-on-a-logic/m-p/852760#M37488</guid>
      <dc:creator>Kirito1</dc:creator>
      <dc:date>2023-01-09T11:29:35Z</dc:date>
    </item>
    <item>
      <title>Re: Add Column Based on a logic</title>
      <link>https://communities.sas.com/t5/New-SAS-User/Add-Column-Based-on-a-logic/m-p/852762#M37489</link>
      <description>I am not even sure the pseudo code I wrote is correct or not.</description>
      <pubDate>Mon, 09 Jan 2023 11:34:33 GMT</pubDate>
      <guid>https://communities.sas.com/t5/New-SAS-User/Add-Column-Based-on-a-logic/m-p/852762#M37489</guid>
      <dc:creator>Kirito1</dc:creator>
      <dc:date>2023-01-09T11:34:33Z</dc:date>
    </item>
    <item>
      <title>Re: Add Column Based on a logic</title>
      <link>https://communities.sas.com/t5/New-SAS-User/Add-Column-Based-on-a-logic/m-p/852763#M37490</link>
      <description>Take a look at the COALESCE function.</description>
      <pubDate>Mon, 09 Jan 2023 11:38:48 GMT</pubDate>
      <guid>https://communities.sas.com/t5/New-SAS-User/Add-Column-Based-on-a-logic/m-p/852763#M37490</guid>
      <dc:creator>Astounding</dc:creator>
      <dc:date>2023-01-09T11:38:48Z</dc:date>
    </item>
    <item>
      <title>Re: Add Column Based on a logic</title>
      <link>https://communities.sas.com/t5/New-SAS-User/Add-Column-Based-on-a-logic/m-p/852765#M37491</link>
      <description>Can you suggest any quick pseudo code for this ...........Although I am reading the function you suggested.</description>
      <pubDate>Mon, 09 Jan 2023 11:42:03 GMT</pubDate>
      <guid>https://communities.sas.com/t5/New-SAS-User/Add-Column-Based-on-a-logic/m-p/852765#M37491</guid>
      <dc:creator>Kirito1</dc:creator>
      <dc:date>2023-01-09T11:42:03Z</dc:date>
    </item>
    <item>
      <title>Re: Add Column Based on a logic</title>
      <link>https://communities.sas.com/t5/New-SAS-User/Add-Column-Based-on-a-logic/m-p/852766#M37492</link>
      <description>&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data want;
    set have;
    ref_code=coalesce(lc_code,lg_code);
run;&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Mon, 09 Jan 2023 11:45:52 GMT</pubDate>
      <guid>https://communities.sas.com/t5/New-SAS-User/Add-Column-Based-on-a-logic/m-p/852766#M37492</guid>
      <dc:creator>PaigeMiller</dc:creator>
      <dc:date>2023-01-09T11:45:52Z</dc:date>
    </item>
    <item>
      <title>Re: Add Column Based on a logic</title>
      <link>https://communities.sas.com/t5/New-SAS-User/Add-Column-Based-on-a-logic/m-p/852767#M37493</link>
      <description>yep its working thank you</description>
      <pubDate>Mon, 09 Jan 2023 11:47:20 GMT</pubDate>
      <guid>https://communities.sas.com/t5/New-SAS-User/Add-Column-Based-on-a-logic/m-p/852767#M37493</guid>
      <dc:creator>Kirito1</dc:creator>
      <dc:date>2023-01-09T11:47:20Z</dc:date>
    </item>
  </channel>
</rss>

