<?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: How to create a new variable while using one-to-one merging in New SAS User</title>
    <link>https://communities.sas.com/t5/New-SAS-User/How-to-create-a-new-variable-while-using-one-to-one-merging/m-p/520095#M3941</link>
    <description>&lt;P&gt;Thank you so much Reeza!&lt;/P&gt;</description>
    <pubDate>Mon, 10 Dec 2018 18:37:08 GMT</pubDate>
    <dc:creator>sasnewbie5</dc:creator>
    <dc:date>2018-12-10T18:37:08Z</dc:date>
    <item>
      <title>How to create a new variable while using one-to-one merging</title>
      <link>https://communities.sas.com/t5/New-SAS-User/How-to-create-a-new-variable-while-using-one-to-one-merging/m-p/520068#M3927</link>
      <description>&lt;P&gt;&amp;nbsp;I have two separate datasets that I want to merge into one new data set. One dataset has the variables "name" and "employee id". The other has variables "salary" and "ID". I need to combine the two data sets and only list the "name" and "salary" variables in the new data set. How would I do that? The code I have so far lists all of the variables in both datasets and I'm not quite sure how to specify only the ones that I want.&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;*Of note, in the first dataset, it's called "EmpID" and in the second it's called "ID".&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Any and all help is welcomed! Thanks!&lt;/P&gt;</description>
      <pubDate>Mon, 10 Dec 2018 17:48:31 GMT</pubDate>
      <guid>https://communities.sas.com/t5/New-SAS-User/How-to-create-a-new-variable-while-using-one-to-one-merging/m-p/520068#M3927</guid>
      <dc:creator>sasnewbie5</dc:creator>
      <dc:date>2018-12-10T17:48:31Z</dc:date>
    </item>
    <item>
      <title>Re: How to create a new variable while using one-to-one merging</title>
      <link>https://communities.sas.com/t5/New-SAS-User/How-to-create-a-new-variable-while-using-one-to-one-merging/m-p/520069#M3928</link>
      <description>&lt;P&gt;Since there is no example data and going with your question, it appears all you need is rename one of your id as the other id name and keep only the variables your want&lt;/P&gt;</description>
      <pubDate>Mon, 10 Dec 2018 17:51:20 GMT</pubDate>
      <guid>https://communities.sas.com/t5/New-SAS-User/How-to-create-a-new-variable-while-using-one-to-one-merging/m-p/520069#M3928</guid>
      <dc:creator>novinosrin</dc:creator>
      <dc:date>2018-12-10T17:51:20Z</dc:date>
    </item>
    <item>
      <title>Re: How to create a new variable while using one-to-one merging</title>
      <link>https://communities.sas.com/t5/New-SAS-User/How-to-create-a-new-variable-while-using-one-to-one-merging/m-p/520071#M3929</link>
      <description>&lt;P&gt;I don't follow. The code I have is as follows:&lt;/P&gt;&lt;P&gt;/*******/&lt;/P&gt;&lt;P&gt;data Dept1;&lt;BR /&gt;set hw8.dept1names;&lt;BR /&gt;set hw8.dept1salaries;&lt;BR /&gt;run;&lt;/P&gt;&lt;P&gt;/******/&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Since I haven't specified any variables, how would I rename it? I'd prefer not to adjust any of the actual dataset content.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Also, I have the two datasets that I'm referring to but I'm not sure if I can upload them to this thread or not. As you can probably tell, I'm very new to SAS and the SAS community.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Mon, 10 Dec 2018 17:55:44 GMT</pubDate>
      <guid>https://communities.sas.com/t5/New-SAS-User/How-to-create-a-new-variable-while-using-one-to-one-merging/m-p/520071#M3929</guid>
      <dc:creator>sasnewbie5</dc:creator>
      <dc:date>2018-12-10T17:55:44Z</dc:date>
    </item>
    <item>
      <title>Re: How to create a new variable while using one-to-one merging</title>
      <link>https://communities.sas.com/t5/New-SAS-User/How-to-create-a-new-variable-while-using-one-to-one-merging/m-p/520072#M3930</link>
      <description>&lt;P&gt;Can you plz post a sample of your two datasets and your expected output. A small sample with 5 records or so will help. Thank you&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Then you tell us your constraints/rules&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Mon, 10 Dec 2018 17:59:22 GMT</pubDate>
      <guid>https://communities.sas.com/t5/New-SAS-User/How-to-create-a-new-variable-while-using-one-to-one-merging/m-p/520072#M3930</guid>
      <dc:creator>novinosrin</dc:creator>
      <dc:date>2018-12-10T17:59:22Z</dc:date>
    </item>
    <item>
      <title>Re: How to create a new variable while using one-to-one merging</title>
      <link>https://communities.sas.com/t5/New-SAS-User/How-to-create-a-new-variable-while-using-one-to-one-merging/m-p/520078#M3931</link>
      <description>&lt;P&gt;See the different examples of merges in the documentation and find the one closes to your situation. Pretty sure it's covered here: &lt;BR /&gt;&lt;A href="https://documentation.sas.com/?docsetId=lestmtsref&amp;amp;docsetTarget=n1i8w2bwu1fn5kn1gpxj18xttbb0.htm&amp;amp;docsetVersion=9.4&amp;amp;locale=en" target="_blank"&gt;https://documentation.sas.com/?docsetId=lestmtsref&amp;amp;docsetTarget=n1i8w2bwu1fn5kn1gpxj18xttbb0.htm&amp;amp;docsetVersion=9.4&amp;amp;locale=en&lt;/A&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;BLOCKQUOTE&gt;&lt;HR /&gt;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/227522"&gt;@sasnewbie5&lt;/a&gt;&amp;nbsp;wrote:&lt;BR /&gt;
&lt;P&gt;I don't follow. The code I have is as follows:&lt;/P&gt;
&lt;P&gt;/*******/&lt;/P&gt;
&lt;P&gt;data Dept1;&lt;BR /&gt;set hw8.dept1names;&lt;BR /&gt;set hw8.dept1salaries;&lt;BR /&gt;run;&lt;/P&gt;
&lt;P&gt;/******/&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Since I haven't specified any variables, how would I rename it? I'd prefer not to adjust any of the actual dataset content.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Also, I have the two datasets that I'm referring to but I'm not sure if I can upload them to this thread or not. As you can probably tell, I'm very new to SAS and the SAS community.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;HR /&gt;&lt;/BLOCKQUOTE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Mon, 10 Dec 2018 18:03:39 GMT</pubDate>
      <guid>https://communities.sas.com/t5/New-SAS-User/How-to-create-a-new-variable-while-using-one-to-one-merging/m-p/520078#M3931</guid>
      <dc:creator>Reeza</dc:creator>
      <dc:date>2018-12-10T18:03:39Z</dc:date>
    </item>
    <item>
      <title>Re: How to create a new variable while using one-to-one merging</title>
      <link>https://communities.sas.com/t5/New-SAS-User/How-to-create-a-new-variable-while-using-one-to-one-merging/m-p/520079#M3932</link>
      <description>&lt;P&gt;I have attached a screenshot of the two datasets to this thread.&lt;/P&gt;&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="Screen Shot 2018-12-10 at 1.00.06 PM.png" style="width: 375px;"&gt;&lt;img src="https://communities.sas.com/t5/image/serverpage/image-id/25524i366A70C9C406FC85/image-size/large?v=v2&amp;amp;px=999" role="button" title="Screen Shot 2018-12-10 at 1.00.06 PM.png" alt="Screen Shot 2018-12-10 at 1.00.06 PM.png" /&gt;&lt;/span&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="Screen Shot 2018-12-10 at 1.00.14 PM.png" style="width: 396px;"&gt;&lt;img src="https://communities.sas.com/t5/image/serverpage/image-id/25523i98D91D1C403BDFFA/image-size/large?v=v2&amp;amp;px=999" role="button" title="Screen Shot 2018-12-10 at 1.00.14 PM.png" alt="Screen Shot 2018-12-10 at 1.00.14 PM.png" /&gt;&lt;/span&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;The expected output is to use one-to-one merging to combine the two datasets and then list&amp;nbsp;just the name and salary in the newly created dataset.&lt;/P&gt;</description>
      <pubDate>Mon, 10 Dec 2018 18:03:31 GMT</pubDate>
      <guid>https://communities.sas.com/t5/New-SAS-User/How-to-create-a-new-variable-while-using-one-to-one-merging/m-p/520079#M3932</guid>
      <dc:creator>sasnewbie5</dc:creator>
      <dc:date>2018-12-10T18:03:31Z</dc:date>
    </item>
    <item>
      <title>Re: How to create a new variable while using one-to-one merging</title>
      <link>https://communities.sas.com/t5/New-SAS-User/How-to-create-a-new-variable-while-using-one-to-one-merging/m-p/520080#M3933</link>
      <description>&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data one;
input name $ empid $;
cards;
nelson 254
mitchell 362
perez 910
carter 935
;
data two;
input salary  id $;
cards;
103100 254
100200 362
73500 910
88400 935
;

data want;
merge one two;
keep name salary;
run;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;NOTES:&lt;/P&gt;
&lt;P&gt;1. The above assumes you really are after a one to one merge and the records in both datasets matches rather having to do an inner join&lt;/P&gt;
&lt;P&gt;2. Both datasets have the same number of obs.&amp;nbsp;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Mon, 10 Dec 2018 18:14:03 GMT</pubDate>
      <guid>https://communities.sas.com/t5/New-SAS-User/How-to-create-a-new-variable-while-using-one-to-one-merging/m-p/520080#M3933</guid>
      <dc:creator>novinosrin</dc:creator>
      <dc:date>2018-12-10T18:14:03Z</dc:date>
    </item>
    <item>
      <title>Re: How to create a new variable while using one-to-one merging</title>
      <link>https://communities.sas.com/t5/New-SAS-User/How-to-create-a-new-variable-while-using-one-to-one-merging/m-p/520082#M3934</link>
      <description>A screenshot means someone needs to type out your data to work with it. &lt;BR /&gt;Instructions on posting your data set is here:&lt;BR /&gt;&lt;A href="https://communities.sas.com/t5/SAS-Communities-Library/How-to-create-a-data-step-version-of-your-data-AKA-generate/ta-p/258712" target="_blank"&gt;https://communities.sas.com/t5/SAS-Communities-Library/How-to-create-a-data-step-version-of-your-data-AKA-generate/ta-p/258712&lt;/A&gt;</description>
      <pubDate>Mon, 10 Dec 2018 18:18:17 GMT</pubDate>
      <guid>https://communities.sas.com/t5/New-SAS-User/How-to-create-a-new-variable-while-using-one-to-one-merging/m-p/520082#M3934</guid>
      <dc:creator>Reeza</dc:creator>
      <dc:date>2018-12-10T18:18:17Z</dc:date>
    </item>
    <item>
      <title>Re: How to create a new variable while using one-to-one merging</title>
      <link>https://communities.sas.com/t5/New-SAS-User/How-to-create-a-new-variable-while-using-one-to-one-merging/m-p/520084#M3935</link>
      <description>You need to join by ID, joining by record assumes order which I strongly suspect is not correct.</description>
      <pubDate>Mon, 10 Dec 2018 18:19:16 GMT</pubDate>
      <guid>https://communities.sas.com/t5/New-SAS-User/How-to-create-a-new-variable-while-using-one-to-one-merging/m-p/520084#M3935</guid>
      <dc:creator>Reeza</dc:creator>
      <dc:date>2018-12-10T18:19:16Z</dc:date>
    </item>
    <item>
      <title>Re: How to create a new variable while using one-to-one merging</title>
      <link>https://communities.sas.com/t5/New-SAS-User/How-to-create-a-new-variable-while-using-one-to-one-merging/m-p/520085#M3936</link>
      <description>&lt;P&gt;Thank you! You mentioned inner joins.&amp;nbsp;All of the examples I've found online are showing it using only SQL statements. Is that the only way to address what you mentioned?&lt;/P&gt;</description>
      <pubDate>Mon, 10 Dec 2018 18:25:56 GMT</pubDate>
      <guid>https://communities.sas.com/t5/New-SAS-User/How-to-create-a-new-variable-while-using-one-to-one-merging/m-p/520085#M3936</guid>
      <dc:creator>sasnewbie5</dc:creator>
      <dc:date>2018-12-10T18:25:56Z</dc:date>
    </item>
    <item>
      <title>Re: How to create a new variable while using one-to-one merging</title>
      <link>https://communities.sas.com/t5/New-SAS-User/How-to-create-a-new-variable-while-using-one-to-one-merging/m-p/520088#M3937</link>
      <description>&lt;P&gt;Thanks Reeza! Is using SQL queries the only way to do an inner join in SAS? So far that's all I've found for creating an inner join.&lt;/P&gt;</description>
      <pubDate>Mon, 10 Dec 2018 18:27:47 GMT</pubDate>
      <guid>https://communities.sas.com/t5/New-SAS-User/How-to-create-a-new-variable-while-using-one-to-one-merging/m-p/520088#M3937</guid>
      <dc:creator>sasnewbie5</dc:creator>
      <dc:date>2018-12-10T18:27:47Z</dc:date>
    </item>
    <item>
      <title>Re: How to create a new variable while using one-to-one merging</title>
      <link>https://communities.sas.com/t5/New-SAS-User/How-to-create-a-new-variable-while-using-one-to-one-merging/m-p/520089#M3938</link>
      <description>&lt;P&gt;I am glad, now you are talking and I am glad I mentioned my assumptions in those 2 points It;s safe to do the inner join and since you have different var names for id's, use sql like&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;
proc sql;
create table want as
select name,salary
from one , two 
where empid=id;
quit;
&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;Basically, you can avoid rename and sort with sql joins as opposed to datastep merge, and since it's a one to one, it's straight forward&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Mon, 10 Dec 2018 18:31:10 GMT</pubDate>
      <guid>https://communities.sas.com/t5/New-SAS-User/How-to-create-a-new-variable-while-using-one-to-one-merging/m-p/520089#M3938</guid>
      <dc:creator>novinosrin</dc:creator>
      <dc:date>2018-12-10T18:31:10Z</dc:date>
    </item>
    <item>
      <title>Re: How to create a new variable while using one-to-one merging</title>
      <link>https://communities.sas.com/t5/New-SAS-User/How-to-create-a-new-variable-while-using-one-to-one-merging/m-p/520091#M3939</link>
      <description>&lt;BLOCKQUOTE&gt;&lt;HR /&gt;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/227522"&gt;@sasnewbie5&lt;/a&gt;&amp;nbsp;wrote:&lt;BR /&gt;
&lt;P&gt;Thank you! You mentioned inner joins.&amp;nbsp;All of the examples I've found online are showing it using only SQL statements. Is that the only way to address what you mentioned?&lt;/P&gt;
&lt;HR /&gt;&lt;/BLOCKQUOTE&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data want;
merge one (in=a) two (in=b rename=(id=empid)) ;
by empid;

if a and b;

keep name salary;
run;&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Mon, 10 Dec 2018 18:34:17 GMT</pubDate>
      <guid>https://communities.sas.com/t5/New-SAS-User/How-to-create-a-new-variable-while-using-one-to-one-merging/m-p/520091#M3939</guid>
      <dc:creator>Reeza</dc:creator>
      <dc:date>2018-12-10T18:34:17Z</dc:date>
    </item>
    <item>
      <title>Re: How to create a new variable while using one-to-one merging</title>
      <link>https://communities.sas.com/t5/New-SAS-User/How-to-create-a-new-variable-while-using-one-to-one-merging/m-p/520092#M3940</link>
      <description>&lt;P&gt;Got it, thanks so much for the clarification!&lt;/P&gt;</description>
      <pubDate>Mon, 10 Dec 2018 18:34:33 GMT</pubDate>
      <guid>https://communities.sas.com/t5/New-SAS-User/How-to-create-a-new-variable-while-using-one-to-one-merging/m-p/520092#M3940</guid>
      <dc:creator>sasnewbie5</dc:creator>
      <dc:date>2018-12-10T18:34:33Z</dc:date>
    </item>
    <item>
      <title>Re: How to create a new variable while using one-to-one merging</title>
      <link>https://communities.sas.com/t5/New-SAS-User/How-to-create-a-new-variable-while-using-one-to-one-merging/m-p/520095#M3941</link>
      <description>&lt;P&gt;Thank you so much Reeza!&lt;/P&gt;</description>
      <pubDate>Mon, 10 Dec 2018 18:37:08 GMT</pubDate>
      <guid>https://communities.sas.com/t5/New-SAS-User/How-to-create-a-new-variable-while-using-one-to-one-merging/m-p/520095#M3941</guid>
      <dc:creator>sasnewbie5</dc:creator>
      <dc:date>2018-12-10T18:37:08Z</dc:date>
    </item>
  </channel>
</rss>

