<?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: Merging variables in SAS in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/Merging-variables-in-SAS/m-p/488672#M127401</link>
    <description>&lt;P&gt;There is no need to do this.&amp;nbsp; If you want to merge two data sets, you are allowed to use more than one variable in the BY statement:&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;data want;&lt;/P&gt;
&lt;P&gt;merge dataset1 dataset2;&lt;/P&gt;
&lt;P&gt;by var1 var2;&lt;/P&gt;
&lt;P&gt;run;&lt;/P&gt;</description>
    <pubDate>Tue, 21 Aug 2018 18:54:07 GMT</pubDate>
    <dc:creator>Astounding</dc:creator>
    <dc:date>2018-08-21T18:54:07Z</dc:date>
    <item>
      <title>Merging variables in SAS</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Merging-variables-in-SAS/m-p/488657#M127394</link>
      <description>&lt;P&gt;Hello,&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I have a data set which has two different variables.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Var1: household&lt;/P&gt;&lt;P&gt;Var2: Person in one specific household&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;To get a unique respondent I need to merge Var1 an Var 2. I can't seem to figure out how to do this in SAS? I have tried some code but it doesn't make sense to me. Once I have merged these two variables. I then need to merge two datasets that both contain that merged variable.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Thank you very much&lt;/P&gt;</description>
      <pubDate>Tue, 21 Aug 2018 18:24:44 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Merging-variables-in-SAS/m-p/488657#M127394</guid>
      <dc:creator>kari</dc:creator>
      <dc:date>2018-08-21T18:24:44Z</dc:date>
    </item>
    <item>
      <title>Re: Merging variables in SAS</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Merging-variables-in-SAS/m-p/488667#M127399</link>
      <description>&lt;P&gt;merge: combine&amp;nbsp;&lt;EM&gt;datasets&lt;/EM&gt; side-by-side.&lt;/P&gt;
&lt;P&gt;You never "merge" variables. Variables can be concatenated.&lt;/P&gt;
&lt;P&gt;Look if the catx() function does what you want.&lt;/P&gt;</description>
      <pubDate>Tue, 21 Aug 2018 18:49:41 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Merging-variables-in-SAS/m-p/488667#M127399</guid>
      <dc:creator>Kurt_Bremser</dc:creator>
      <dc:date>2018-08-21T18:49:41Z</dc:date>
    </item>
    <item>
      <title>Re: Merging variables in SAS</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Merging-variables-in-SAS/m-p/488672#M127401</link>
      <description>&lt;P&gt;There is no need to do this.&amp;nbsp; If you want to merge two data sets, you are allowed to use more than one variable in the BY statement:&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;data want;&lt;/P&gt;
&lt;P&gt;merge dataset1 dataset2;&lt;/P&gt;
&lt;P&gt;by var1 var2;&lt;/P&gt;
&lt;P&gt;run;&lt;/P&gt;</description>
      <pubDate>Tue, 21 Aug 2018 18:54:07 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Merging-variables-in-SAS/m-p/488672#M127401</guid>
      <dc:creator>Astounding</dc:creator>
      <dc:date>2018-08-21T18:54:07Z</dc:date>
    </item>
    <item>
      <title>Re: Merging variables in SAS</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Merging-variables-in-SAS/m-p/488675#M127402</link>
      <description>Almost always posting examples of the data you have and what you need as result increases the likelihood that someone posts usable code.</description>
      <pubDate>Tue, 21 Aug 2018 19:00:16 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Merging-variables-in-SAS/m-p/488675#M127402</guid>
      <dc:creator>error_prone</dc:creator>
      <dc:date>2018-08-21T19:00:16Z</dc:date>
    </item>
    <item>
      <title>Re: Merging variables in SAS</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Merging-variables-in-SAS/m-p/488676#M127403</link>
      <description>&lt;P&gt;Not sure if I understood your problem, Are you trying to find the var1 value in var2 or vice versa and treat them as one common variable. You can either use FIND(), INDEX(), PRXMATCH() function.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;For Example:&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data test ;
Var1="household";
Var2="Person in one specific household";
if find(var1,var2,'i') or find(var2,var1,'i') then var=var2;
run;&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Tue, 21 Aug 2018 19:02:47 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Merging-variables-in-SAS/m-p/488676#M127403</guid>
      <dc:creator>SuryaKiran</dc:creator>
      <dc:date>2018-08-21T19:02:47Z</dc:date>
    </item>
    <item>
      <title>Re: Merging variables in SAS</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Merging-variables-in-SAS/m-p/488987#M127534</link>
      <description>&lt;P&gt;Hi there,&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;The userguide says merge but I think what it means is to combine the two as the information from both together will provide a unique participant. Does this make more sense? Thank you!&lt;/P&gt;</description>
      <pubDate>Wed, 22 Aug 2018 17:26:32 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Merging-variables-in-SAS/m-p/488987#M127534</guid>
      <dc:creator>kari</dc:creator>
      <dc:date>2018-08-22T17:26:32Z</dc:date>
    </item>
    <item>
      <title>Re: Merging variables in SAS</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Merging-variables-in-SAS/m-p/489037#M127559</link>
      <description>&lt;BLOCKQUOTE&gt;&lt;HR /&gt;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/220985"&gt;@kari&lt;/a&gt;&amp;nbsp;wrote:&lt;BR /&gt;
&lt;P&gt;Hi there,&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;The userguide says merge but I think what it means is to combine the two as the information from both together will provide a unique participant. Does this make more sense? Thank you!&lt;/P&gt;
&lt;HR /&gt;&lt;/BLOCKQUOTE&gt;
&lt;P&gt;User guide to what?&lt;/P&gt;
&lt;P&gt;If this is preparing data for use by an external (not SAS) process then say so. Likely that means you want to use one of the concatenation functions, in&amp;nbsp;a data step to combine the two values. Does the user guide provide any hints rules&amp;nbsp;on how to combine them? Such as which order or provide a space between the fields or a special character, ensure only one blank/special character between words or any thing like that?&lt;/P&gt;
&lt;P&gt;Are your current variables character or numeric?&lt;/P&gt;
&lt;P&gt;Can provide a couple of examples of actual values and what the result should look like?&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;I would start with something like:&lt;/P&gt;
&lt;P&gt;data need;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; set have;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; uniqueid = catx(' ',var1, var2);&lt;/P&gt;
&lt;P&gt;run;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;which would create a new variable with the values of the two variables and single space between them.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Wed, 22 Aug 2018 20:20:49 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Merging-variables-in-SAS/m-p/489037#M127559</guid>
      <dc:creator>ballardw</dc:creator>
      <dc:date>2018-08-22T20:20:49Z</dc:date>
    </item>
    <item>
      <title>Re: Merging variables in SAS</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Merging-variables-in-SAS/m-p/489046#M127565</link>
      <description>&lt;P&gt;Right now this is all just guessing on our part. Please post usable example data (data step with datalines, see my footnotes), and what you expect out of it.&lt;/P&gt;</description>
      <pubDate>Wed, 22 Aug 2018 20:55:20 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Merging-variables-in-SAS/m-p/489046#M127565</guid>
      <dc:creator>Kurt_Bremser</dc:creator>
      <dc:date>2018-08-22T20:55:20Z</dc:date>
    </item>
  </channel>
</rss>

