<?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: New column with values from two columns: Choose value from column A if existing, otherwise choos in SAS Enterprise Guide</title>
    <link>https://communities.sas.com/t5/SAS-Enterprise-Guide/New-column-with-values-from-two-columns-Choose-value-from-column/m-p/270024#M18719</link>
    <description>&lt;P&gt;Should your new variable be character or numeric? &amp;nbsp;A numeric variable can't take on the value "no sample". &amp;nbsp;But it can take on a special missing value (such as .N) that would differentiate it from other values. &amp;nbsp;You could use:&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;newvar = coalesce(a, b);&lt;/P&gt;
&lt;P&gt;if newvar=. then newvar=.N;&lt;/P&gt;</description>
    <pubDate>Thu, 12 May 2016 11:40:31 GMT</pubDate>
    <dc:creator>Astounding</dc:creator>
    <dc:date>2016-05-12T11:40:31Z</dc:date>
    <item>
      <title>New column with values from two columns: Choose value from column A if existing, otherwise choose B.</title>
      <link>https://communities.sas.com/t5/SAS-Enterprise-Guide/New-column-with-values-from-two-columns-Choose-value-from-column/m-p/270022#M18718</link>
      <description>&lt;P&gt;I have two columns which I want to combine into one.&lt;/P&gt;&lt;P&gt;It looks like this:&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;A&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; B&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;0.12&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; .&lt;/P&gt;&lt;P&gt;0.02&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; 0.02&lt;/P&gt;&lt;P&gt;0.20&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; 0.28&lt;/P&gt;&lt;P&gt;.&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; .&lt;/P&gt;&lt;P&gt;.&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; 0.12&lt;/P&gt;&lt;P&gt;0.13&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; 0.15&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;For the new column:&lt;/P&gt;&lt;P&gt;In principle I want the value from the column A.&lt;/P&gt;&lt;P&gt;If that value is missing, I want the value from column B.&lt;/P&gt;&lt;P&gt;If both are missing I want ‘no sample’.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Can anyone help me with creating this new column with these values? Thank you!&lt;/P&gt;</description>
      <pubDate>Thu, 12 May 2016 11:20:38 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Enterprise-Guide/New-column-with-values-from-two-columns-Choose-value-from-column/m-p/270022#M18718</guid>
      <dc:creator>MB1</dc:creator>
      <dc:date>2016-05-12T11:20:38Z</dc:date>
    </item>
    <item>
      <title>Re: New column with values from two columns: Choose value from column A if existing, otherwise choos</title>
      <link>https://communities.sas.com/t5/SAS-Enterprise-Guide/New-column-with-values-from-two-columns-Choose-value-from-column/m-p/270024#M18719</link>
      <description>&lt;P&gt;Should your new variable be character or numeric? &amp;nbsp;A numeric variable can't take on the value "no sample". &amp;nbsp;But it can take on a special missing value (such as .N) that would differentiate it from other values. &amp;nbsp;You could use:&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;newvar = coalesce(a, b);&lt;/P&gt;
&lt;P&gt;if newvar=. then newvar=.N;&lt;/P&gt;</description>
      <pubDate>Thu, 12 May 2016 11:40:31 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Enterprise-Guide/New-column-with-values-from-two-columns-Choose-value-from-column/m-p/270024#M18719</guid>
      <dc:creator>Astounding</dc:creator>
      <dc:date>2016-05-12T11:40:31Z</dc:date>
    </item>
    <item>
      <title>Re: New column with values from two columns: Choose value from column A if existing, otherwise choos</title>
      <link>https://communities.sas.com/t5/SAS-Enterprise-Guide/New-column-with-values-from-two-columns-Choose-value-from-column/m-p/270026#M18720</link>
      <description>Thank you very much for your quick reaction! It totally worked.</description>
      <pubDate>Thu, 12 May 2016 11:49:46 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Enterprise-Guide/New-column-with-values-from-two-columns-Choose-value-from-column/m-p/270026#M18720</guid>
      <dc:creator>MB1</dc:creator>
      <dc:date>2016-05-12T11:49:46Z</dc:date>
    </item>
    <item>
      <title>Re: New column with values from two columns: Choose value from column A if existing, otherwise choos</title>
      <link>https://communities.sas.com/t5/SAS-Enterprise-Guide/New-column-with-values-from-two-columns-Choose-value-from-column/m-p/270027#M18721</link>
      <description>&lt;P&gt;I agree with&amp;nbsp;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/4954"&gt;@Astounding﻿&lt;/a&gt;&amp;nbsp;that coalsece is a good idea. &amp;nbsp;I would check the logic when you have both values however, are you sure you want the first and not the min or max? &amp;nbsp;Don't know what your data is also, but in Pharma data where we follow CDISC structures, you should have a numeric and character version of these types of variables, the reason being that you can then capture all numbers in a numerical variable for processing - makes using numbers easy, and also a character representation for reporting which can contain futher information that cannot be captured in a numeric, e.g:&lt;/P&gt;
&lt;P&gt;RESULT &amp;nbsp; &amp;nbsp;RESULT_C&lt;/P&gt;
&lt;P&gt;0.12 &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; 0.12&lt;/P&gt;
&lt;P&gt;. &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; No sample&lt;/P&gt;
&lt;P&gt;...&lt;/P&gt;
&lt;P&gt;E.g:&lt;/P&gt;
&lt;PRE&gt;data want;
  set have;
  result=coalesce(a,b);
  /* Or:  result=min(a,b); */
  result_c=ifc(a=. and b=.,"No sample",strip(put(min(a,b),best.)));
run;&lt;/PRE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;If your using anything other than SAS, I would avoid formats as these are SAS specific and proprietary to the software, the above two columns however are accessible to any other software.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Thu, 12 May 2016 11:50:22 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Enterprise-Guide/New-column-with-values-from-two-columns-Choose-value-from-column/m-p/270027#M18721</guid>
      <dc:creator>RW9</dc:creator>
      <dc:date>2016-05-12T11:50:22Z</dc:date>
    </item>
  </channel>
</rss>

