<?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 merging two variables in one dataset in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/merging-two-variables-in-one-dataset/m-p/732936#M228395</link>
    <description>&lt;P&gt;Hi all,&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I have two variables with the same information, its just one has the missing characters for the other. How do I merge them together to fill in the blanks?&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;For example;&lt;/P&gt;&lt;P&gt;ParkingSpot&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; Comments&lt;/P&gt;&lt;P&gt;1-11-21&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;1-12-22&lt;/P&gt;&lt;P&gt;1-13-23&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I would like it to look like:&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;ParkingSpot&lt;/P&gt;&lt;P&gt;1-11-21&lt;/P&gt;&lt;P&gt;1-12-22&lt;/P&gt;&lt;P&gt;1-13-23&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;How do I achieve this outcome? CAT or Merge?&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Thanks&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
    <pubDate>Mon, 12 Apr 2021 04:15:12 GMT</pubDate>
    <dc:creator>EM_G</dc:creator>
    <dc:date>2021-04-12T04:15:12Z</dc:date>
    <item>
      <title>merging two variables in one dataset</title>
      <link>https://communities.sas.com/t5/SAS-Programming/merging-two-variables-in-one-dataset/m-p/732936#M228395</link>
      <description>&lt;P&gt;Hi all,&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I have two variables with the same information, its just one has the missing characters for the other. How do I merge them together to fill in the blanks?&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;For example;&lt;/P&gt;&lt;P&gt;ParkingSpot&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; Comments&lt;/P&gt;&lt;P&gt;1-11-21&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;1-12-22&lt;/P&gt;&lt;P&gt;1-13-23&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I would like it to look like:&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;ParkingSpot&lt;/P&gt;&lt;P&gt;1-11-21&lt;/P&gt;&lt;P&gt;1-12-22&lt;/P&gt;&lt;P&gt;1-13-23&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;How do I achieve this outcome? CAT or Merge?&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Thanks&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Mon, 12 Apr 2021 04:15:12 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/merging-two-variables-in-one-dataset/m-p/732936#M228395</guid>
      <dc:creator>EM_G</dc:creator>
      <dc:date>2021-04-12T04:15:12Z</dc:date>
    </item>
    <item>
      <title>Re: merging two variables in one dataset</title>
      <link>https://communities.sas.com/t5/SAS-Programming/merging-two-variables-in-one-dataset/m-p/732938#M228396</link>
      <description>&lt;BLOCKQUOTE&gt;&lt;HR /&gt;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/353220"&gt;@EM_G&lt;/a&gt;&amp;nbsp;wrote:&lt;BR /&gt;
&lt;P&gt;Hi all,&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;I have two variables with the same information, its just one has the missing characters for the other. How do I merge them together to fill in the blanks?&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;For example;&lt;/P&gt;
&lt;P&gt;ParkingSpot&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; Comments&lt;/P&gt;
&lt;P&gt;1-11-21&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;1-12-22&lt;/P&gt;
&lt;P&gt;1-13-23&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;I would like it to look like:&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;ParkingSpot&lt;/P&gt;
&lt;P&gt;1-11-21&lt;/P&gt;
&lt;P&gt;1-12-22&lt;/P&gt;
&lt;P&gt;1-13-23&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;How do I achieve this outcome? CAT or Merge?&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Thanks&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;HR /&gt;&lt;/BLOCKQUOTE&gt;
&lt;P&gt;Does "comments" ever hold a value you do not want in the "Parkingspot" variable? And are the variables the same type?&lt;/P&gt;
&lt;P&gt;If the answers above are "no" to the first and "yes" to the second then&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;Data want;
   set have;
   parkingspot= coalescec(parkingspot, comments);
run;&lt;/PRE&gt;
&lt;P&gt;The Coalescec, and the similar for numeric values Coalesce, functions examine the list of values in quotes and returns the first non-missing value.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Merge is data set operation, not variables.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;One of the CAT functions might work but if you ever have both variables with any values the result is likely to be a problem.&lt;/P&gt;</description>
      <pubDate>Mon, 12 Apr 2021 04:43:34 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/merging-two-variables-in-one-dataset/m-p/732938#M228396</guid>
      <dc:creator>ballardw</dc:creator>
      <dc:date>2021-04-12T04:43:34Z</dc:date>
    </item>
    <item>
      <title>Re: merging two variables in one dataset</title>
      <link>https://communities.sas.com/t5/SAS-Programming/merging-two-variables-in-one-dataset/m-p/732952#M228399</link>
      <description>&lt;P&gt;Besides of coalescec() a simple condition would also do the job&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;if missing(parkingspot) then parkingspot=comments;&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Mon, 12 Apr 2021 05:42:26 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/merging-two-variables-in-one-dataset/m-p/732952#M228399</guid>
      <dc:creator>Patrick</dc:creator>
      <dc:date>2021-04-12T05:42:26Z</dc:date>
    </item>
    <item>
      <title>Re: merging two variables in one dataset</title>
      <link>https://communities.sas.com/t5/SAS-Programming/merging-two-variables-in-one-dataset/m-p/732989#M228409</link>
      <description>Thankyou for your helpful explanation. 'comments' hold some random values of no use, but where parkingspots is missing 'comments' has the values needed. If that makes sense.</description>
      <pubDate>Mon, 12 Apr 2021 11:21:07 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/merging-two-variables-in-one-dataset/m-p/732989#M228409</guid>
      <dc:creator>EM_G</dc:creator>
      <dc:date>2021-04-12T11:21:07Z</dc:date>
    </item>
  </channel>
</rss>

