<?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 Issue Merging Two Datasets in SAS Procedures</title>
    <link>https://communities.sas.com/t5/SAS-Procedures/Issue-Merging-Two-Datasets/m-p/25800#M5875</link>
    <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;You will still need to use a retain, length of other statement that can affect variable order.&amp;nbsp; The only time a separate datastep is needed is when you are doing other things like computes, if then computes, etc.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Its use is simply the word retain, followed by a space, followed by all of the variables you want to put at the left most side of the record, in the order that you want them to appear, separated by spaces, and ending the statement with a semicolon.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;The only peculiarity, but this goes with any other statement you might use to reorder your data, is that the statement must appear BEFORE the set (or in your case merge) statement.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
    <pubDate>Sat, 07 Jan 2012 20:58:11 GMT</pubDate>
    <dc:creator>art297</dc:creator>
    <dc:date>2012-01-07T20:58:11Z</dc:date>
    <item>
      <title>Issue Merging Two Datasets</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/Issue-Merging-Two-Datasets/m-p/25794#M5869</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hi all--&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;I am trying to merge two datasets together. When the datasets are merged the variables need to go in a certain order. For dataset Have2 I have series questions which all start with the same prefix like &lt;STRONG&gt;Q15&lt;/STRONG&gt;_1 &lt;STRONG&gt;Q15&lt;/STRONG&gt;_2 &lt;STRONG&gt;Q15&lt;/STRONG&gt;_3...... or like &lt;STRONG&gt;Q55&lt;/STRONG&gt;_1 &lt;STRONG&gt;Q55&lt;/STRONG&gt;_2 &lt;STRONG&gt;Q55&lt;/STRONG&gt;_3 &lt;STRONG&gt;Q55&lt;/STRONG&gt;_4 &lt;STRONG&gt;Q55&lt;/STRONG&gt;_5....... The value _# tagged on the end of the variable can change.&amp;nbsp;&amp;nbsp; To take this into account im useing the wildcard "&lt;STRONG&gt;:" &lt;/STRONG&gt;to generate lists of variables with these prefixes.&amp;nbsp; &lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Please see my code below. &lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Here is my issue: Variables that start with Q55 or Q15&amp;nbsp; wich are also contained in Have1 are being pulled in to Want, which they should not be. These types of variables need to only be pulled in from Have2. Again, the variables brought in from Have1 and Have2 must fall into a certain order for Want.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;data Want; &lt;/P&gt;&lt;P&gt;merge Have1 Have2;&lt;/P&gt;&lt;P&gt;keep &lt;/P&gt;&lt;P&gt;CASE_NO /*from&amp;nbsp; Have1 */ &lt;/P&gt;&lt;P&gt;Agency_Name /*from&amp;nbsp; Have1 */ &lt;/P&gt;&lt;P&gt;Program_Name /*from&amp;nbsp; Have1 */ &lt;/P&gt;&lt;P&gt;Q55: /*from&amp;nbsp; Have2 */ &lt;/P&gt;&lt;P&gt;CONNX_CaseID /*from&amp;nbsp; Have1 */ &lt;/P&gt;&lt;P&gt;Q15: /*from&amp;nbsp; Have2 */ &lt;/P&gt;&lt;P&gt;Case_Name /*from&amp;nbsp; Have1 */ &lt;/P&gt;&lt;P&gt;Case_Age /*from&amp;nbsp; Have1 */ &lt;/P&gt;&lt;P&gt;by CASE_NO;&lt;/P&gt;&lt;P&gt;run;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Any help is greatly aperciated. Thank you.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Sat, 07 Jan 2012 19:17:11 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/Issue-Merging-Two-Datasets/m-p/25794#M5869</guid>
      <dc:creator>Mgarret</dc:creator>
      <dc:date>2012-01-07T19:17:11Z</dc:date>
    </item>
    <item>
      <title>Re: Issue Merging Two Datasets</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/Issue-Merging-Two-Datasets/m-p/25795#M5870</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;change your code to:&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;data Want;&lt;/P&gt;&lt;P&gt;merge Have1(keep=case_:&amp;nbsp; Agency_Name Program_Name CONNX_CaseID)&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; Have2(keep=case_no q55: q15:);&lt;/P&gt;&lt;P&gt;by CASE_NO;&lt;/P&gt;&lt;P&gt;run;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Linlin&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Sat, 07 Jan 2012 19:27:44 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/Issue-Merging-Two-Datasets/m-p/25795#M5870</guid>
      <dc:creator>Linlin</dc:creator>
      <dc:date>2012-01-07T19:27:44Z</dc:date>
    </item>
    <item>
      <title>Issue Merging Two Datasets</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/Issue-Merging-Two-Datasets/m-p/25796#M5871</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Why not simply drop them in your merge statement?&amp;nbsp; I.e.,&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P style="background-color: #eef4f9;"&gt;data Want;&lt;/P&gt;&lt;P style="background-color: #eef4f9;"&gt;merge Have1 (drop=q55: q15:)&amp;nbsp; Have2;&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Sat, 07 Jan 2012 19:29:20 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/Issue-Merging-Two-Datasets/m-p/25796#M5871</guid>
      <dc:creator>art297</dc:creator>
      <dc:date>2012-01-07T19:29:20Z</dc:date>
    </item>
    <item>
      <title>Issue Merging Two Datasets</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/Issue-Merging-Two-Datasets/m-p/25797#M5872</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Ok. I see... and then use another Data step to organize the &lt;SPAN style="background-color: #eef4f9;"&gt;variables &lt;/SPAN&gt;in their correct order, right? &lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Sat, 07 Jan 2012 19:38:12 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/Issue-Merging-Two-Datasets/m-p/25797#M5872</guid>
      <dc:creator>Mgarret</dc:creator>
      <dc:date>2012-01-07T19:38:12Z</dc:date>
    </item>
    <item>
      <title>Issue Merging Two Datasets</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/Issue-Merging-Two-Datasets/m-p/25798#M5873</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Why?&amp;nbsp; As long as you aren't doing any data manipulation other than the merge, why not include a retain statement within the same datastep as the merge .. right after the initial data statement?&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Sat, 07 Jan 2012 19:47:19 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/Issue-Merging-Two-Datasets/m-p/25798#M5873</guid>
      <dc:creator>art297</dc:creator>
      <dc:date>2012-01-07T19:47:19Z</dc:date>
    </item>
    <item>
      <title>Issue Merging Two Datasets</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/Issue-Merging-Two-Datasets/m-p/25799#M5874</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Ok. Thanks. I am not too familar with the &lt;SPAN style="background-color: #ffffff;"&gt;retain statement so it might be easier for me to just make another datastep. &lt;/SPAN&gt;&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Sat, 07 Jan 2012 19:50:31 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/Issue-Merging-Two-Datasets/m-p/25799#M5874</guid>
      <dc:creator>Mgarret</dc:creator>
      <dc:date>2012-01-07T19:50:31Z</dc:date>
    </item>
    <item>
      <title>Issue Merging Two Datasets</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/Issue-Merging-Two-Datasets/m-p/25800#M5875</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;You will still need to use a retain, length of other statement that can affect variable order.&amp;nbsp; The only time a separate datastep is needed is when you are doing other things like computes, if then computes, etc.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Its use is simply the word retain, followed by a space, followed by all of the variables you want to put at the left most side of the record, in the order that you want them to appear, separated by spaces, and ending the statement with a semicolon.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;The only peculiarity, but this goes with any other statement you might use to reorder your data, is that the statement must appear BEFORE the set (or in your case merge) statement.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Sat, 07 Jan 2012 20:58:11 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/Issue-Merging-Two-Datasets/m-p/25800#M5875</guid>
      <dc:creator>art297</dc:creator>
      <dc:date>2012-01-07T20:58:11Z</dc:date>
    </item>
    <item>
      <title>Issue Merging Two Datasets</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/Issue-Merging-Two-Datasets/m-p/25801#M5876</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Why do you need the variables in a certain order. Just becuase it's nice?&lt;/P&gt;&lt;P&gt;Any time when you query data can specify a desired variable order, or you can have a view (or information map) on top of the table.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;/Linus&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Sun, 08 Jan 2012 17:25:22 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/Issue-Merging-Two-Datasets/m-p/25801#M5876</guid>
      <dc:creator>LinusH</dc:creator>
      <dc:date>2012-01-08T17:25:22Z</dc:date>
    </item>
  </channel>
</rss>

