<?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: Merge two datasets in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/Merge-two-datasets/m-p/821654#M324399</link>
    <description>&lt;BLOCKQUOTE&gt;
&lt;P&gt;I tried to merge the data set by year as it is the only variable that matches both datasets, but it did not work.&lt;/P&gt;
&lt;/BLOCKQUOTE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Saying "it did not work" and stopping there gives us no information about why it didn't work. &lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;If there are errors in the log, then show us the &lt;FONT color="#FF0000"&gt;entire&lt;/FONT&gt; log for this merge step, every single line, with nothing chopped out. Copy the log as text and paste it into the window that appears when you click on the &amp;lt;/&amp;gt; icon.&lt;/P&gt;
&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="Insert Log Icon in SAS Communities.png" style="width: 859px;"&gt;&lt;img src="https://communities.sas.com/t5/image/serverpage/image-id/66171iFEC370B1DBF07B28/image-size/large?v=v2&amp;amp;px=999" role="button" title="Insert Log Icon in SAS Communities.png" alt="Insert Log Icon in SAS Communities.png" /&gt;&lt;/span&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;If the output was not correct, then show us the output you got and the desired output.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Lastly, we cannot write programs to read data from screen captures. Data MUST be provided as SAS data step code, which you can type in yourself of follow &lt;A href="https://blogs.sas.com/content/sastraining/2016/03/11/jedi-sas-tricks-data-to-data-step-macro/" target="_self"&gt;these instructions&lt;/A&gt;.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
    <pubDate>Tue, 05 Jul 2022 18:43:36 GMT</pubDate>
    <dc:creator>PaigeMiller</dc:creator>
    <dc:date>2022-07-05T18:43:36Z</dc:date>
    <item>
      <title>Merge two datasets</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Merge-two-datasets/m-p/821626#M324387</link>
      <description>&lt;P&gt;Hi,&lt;/P&gt;&lt;P&gt;I am trying to merge two datasets: dataset A and dataset B, and at the same time, I want to do some calculations based on the TOTAL and the LOS_TOTAL. I tried to merge the data set by year as it is the only variable that matches both datasets, but it did not work. I used the following data step:-&lt;/P&gt;&lt;P&gt;Data test;&lt;BR /&gt;Set test1;&lt;BR /&gt;Merge work.A&lt;BR /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; Work.B;&lt;BR /&gt;By year;&lt;BR /&gt;Run;&lt;/P&gt;&lt;P&gt;The merge should be based on the value (0,1) for variables (_3WX _2SF&amp;nbsp;&amp;nbsp;&amp;nbsp; _4SQ&amp;nbsp;&amp;nbsp; _6SR&amp;nbsp;&amp;nbsp; _7SF&amp;nbsp;&amp;nbsp;&amp;nbsp; _7WO 7ICU&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; _5AA), if the value is 1 then take the same values of GRE and ZDF from the dataset B. If it is 0, then ignore it. &amp;nbsp;If one observation contains value 1 in two different variables, then do a calculation. For example (ID 3 has value 1 for _2SF and _7ICU).&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Now, I am stuck. I don’t know how to merge them. Also, I want to do the following calculation (e.g., ID 3):-&lt;/P&gt;&lt;P&gt;If total &amp;gt; 1 then GRE =&lt;/P&gt;&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="Tamertmg_5-1657033134912.png" style="width: 400px;"&gt;&lt;img src="https://communities.sas.com/t5/image/serverpage/image-id/72929i7037BD033DF2ECB5/image-size/medium?v=v2&amp;amp;px=400" role="button" title="Tamertmg_5-1657033134912.png" alt="Tamertmg_5-1657033134912.png" /&gt;&lt;/span&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;ZDF =&lt;/P&gt;&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="Tamertmg_6-1657033134922.png" style="width: 400px;"&gt;&lt;img src="https://communities.sas.com/t5/image/serverpage/image-id/72930i5A15188C7BAC84F1/image-size/medium?v=v2&amp;amp;px=400" role="button" title="Tamertmg_6-1657033134922.png" alt="Tamertmg_6-1657033134922.png" /&gt;&lt;/span&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="Tamertmg_7-1657033134943.png" style="width: 743px;"&gt;&lt;img src="https://communities.sas.com/t5/image/serverpage/image-id/72931i148E78E31E712AF5/image-dimensions/743x113?v=v2" width="743" height="113" role="button" title="Tamertmg_7-1657033134943.png" alt="Tamertmg_7-1657033134943.png" /&gt;&lt;/span&gt;&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;Figure &lt;/STRONG&gt;&lt;STRONG&gt;1&lt;/STRONG&gt;&lt;STRONG&gt; dataset A&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="Tamertmg_8-1657033134983.png" style="width: 400px;"&gt;&lt;img src="https://communities.sas.com/t5/image/serverpage/image-id/72932i2113F3DF572C8DFD/image-size/medium?v=v2&amp;amp;px=400" role="button" title="Tamertmg_8-1657033134983.png" alt="Tamertmg_8-1657033134983.png" /&gt;&lt;/span&gt;&lt;/P&gt;&lt;P&gt;Figure 2. Dataset B&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;The outcome should be like this:-&lt;/P&gt;&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="Tamertmg_9-1657033135007.png" style="width: 400px;"&gt;&lt;img src="https://communities.sas.com/t5/image/serverpage/image-id/72933i24AC28B6014E58AF/image-size/medium?v=v2&amp;amp;px=400" role="button" title="Tamertmg_9-1657033135007.png" alt="Tamertmg_9-1657033135007.png" /&gt;&lt;/span&gt;&lt;/P&gt;&lt;P&gt;Figure 3. Desired outcomes&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Thank you&lt;/P&gt;</description>
      <pubDate>Tue, 05 Jul 2022 15:00:07 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Merge-two-datasets/m-p/821626#M324387</guid>
      <dc:creator>Tamertmg</dc:creator>
      <dc:date>2022-07-05T15:00:07Z</dc:date>
    </item>
    <item>
      <title>Re: Merge two datasets</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Merge-two-datasets/m-p/821654#M324399</link>
      <description>&lt;BLOCKQUOTE&gt;
&lt;P&gt;I tried to merge the data set by year as it is the only variable that matches both datasets, but it did not work.&lt;/P&gt;
&lt;/BLOCKQUOTE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Saying "it did not work" and stopping there gives us no information about why it didn't work. &lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;If there are errors in the log, then show us the &lt;FONT color="#FF0000"&gt;entire&lt;/FONT&gt; log for this merge step, every single line, with nothing chopped out. Copy the log as text and paste it into the window that appears when you click on the &amp;lt;/&amp;gt; icon.&lt;/P&gt;
&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="Insert Log Icon in SAS Communities.png" style="width: 859px;"&gt;&lt;img src="https://communities.sas.com/t5/image/serverpage/image-id/66171iFEC370B1DBF07B28/image-size/large?v=v2&amp;amp;px=999" role="button" title="Insert Log Icon in SAS Communities.png" alt="Insert Log Icon in SAS Communities.png" /&gt;&lt;/span&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;If the output was not correct, then show us the output you got and the desired output.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Lastly, we cannot write programs to read data from screen captures. Data MUST be provided as SAS data step code, which you can type in yourself of follow &lt;A href="https://blogs.sas.com/content/sastraining/2016/03/11/jedi-sas-tricks-data-to-data-step-macro/" target="_self"&gt;these instructions&lt;/A&gt;.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Tue, 05 Jul 2022 18:43:36 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Merge-two-datasets/m-p/821654#M324399</guid>
      <dc:creator>PaigeMiller</dc:creator>
      <dc:date>2022-07-05T18:43:36Z</dc:date>
    </item>
    <item>
      <title>Re: Merge two datasets</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Merge-two-datasets/m-p/821703#M324408</link>
      <description>&lt;P&gt;Which observations for the year "2018/19" do you want to combine?&amp;nbsp; Both of the pictures you posted have multiple observations with that value.&lt;/P&gt;</description>
      <pubDate>Tue, 05 Jul 2022 20:08:43 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Merge-two-datasets/m-p/821703#M324408</guid>
      <dc:creator>Tom</dc:creator>
      <dc:date>2022-07-05T20:08:43Z</dc:date>
    </item>
    <item>
      <title>Re: Merge two datasets</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Merge-two-datasets/m-p/821790#M324458</link>
      <description>Thank you Paige for the reply. I will share the SAS data as per instructions</description>
      <pubDate>Wed, 06 Jul 2022 08:54:21 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Merge-two-datasets/m-p/821790#M324458</guid>
      <dc:creator>Tamertmg</dc:creator>
      <dc:date>2022-07-06T08:54:21Z</dc:date>
    </item>
  </channel>
</rss>

