<?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: Three datasets, same variables, different values - need to combine into one in SAS Procedures</title>
    <link>https://communities.sas.com/t5/SAS-Procedures/Three-datasets-same-variables-different-values-need-to-combine/m-p/25482#M5778</link>
    <description>Assuming variable A has unique value in all three datasets.&lt;BR /&gt;
&lt;BR /&gt;
&lt;BR /&gt;
[pre]&lt;BR /&gt;
data female;&lt;BR /&gt;
 infile datalines truncover;&lt;BR /&gt;
 input a b_f $ c_f $ d_f $ e_f $ f_f $ ;&lt;BR /&gt;
datalines;&lt;BR /&gt;
1 F F&lt;BR /&gt;
2&lt;BR /&gt;
;&lt;BR /&gt;
run;&lt;BR /&gt;
data male;&lt;BR /&gt;
 infile datalines truncover;&lt;BR /&gt;
 input a b_m $ c_m $ d_m $ e_m $ f_m $ ;&lt;BR /&gt;
datalines;&lt;BR /&gt;
1 M&lt;BR /&gt;
2&lt;BR /&gt;
;&lt;BR /&gt;
run;&lt;BR /&gt;
data sibling;&lt;BR /&gt;
 infile datalines truncover;&lt;BR /&gt;
 input a b_s $ c_s $ d_s $ e_s $ f_s $ ;&lt;BR /&gt;
datalines;&lt;BR /&gt;
1 S S&lt;BR /&gt;
2&lt;BR /&gt;
;&lt;BR /&gt;
run;&lt;BR /&gt;
data want;&lt;BR /&gt;
 merge female male sibling;&lt;BR /&gt;
 by a;&lt;BR /&gt;
 length b c d e f $ 10;&lt;BR /&gt;
 b=catt(of b_:);&lt;BR /&gt;
 c=catt(of c_:);&lt;BR /&gt;
 d=catt(of d_:);&lt;BR /&gt;
 e=catt(of e_:);&lt;BR /&gt;
 f=catt(of f_:);&lt;BR /&gt;
 keep a b c d e f;&lt;BR /&gt;
run;&lt;BR /&gt;
&lt;BR /&gt;
[/pre]&lt;BR /&gt;
&lt;BR /&gt;
&lt;BR /&gt;
Ksharp</description>
    <pubDate>Thu, 10 Mar 2011 05:24:47 GMT</pubDate>
    <dc:creator>Ksharp</dc:creator>
    <dc:date>2011-03-10T05:24:47Z</dc:date>
    <item>
      <title>Three datasets, same variables, different values - need to combine into one</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/Three-datasets-same-variables-different-values-need-to-combine/m-p/25478#M5774</link>
      <description>I have three different datasets: Males, Females and Siblings. &lt;BR /&gt;
If there is a significant value present for variables A B C D E F then for the Males an "M" is present, Females an "F" is present and Siblings an "S" is present. I want to combine these three sets together so that if significant values are present for variables A B C D E F for Males, Females and Siblings, the values of lets say B for example would be "MFS". If D is only significant in Females and Siblings, then B would be "FS". &lt;BR /&gt;
Not sure how to do this, have been doing it manually in excel and trying to save time. &lt;BR /&gt;
Example of possible data:&lt;BR /&gt;
&lt;BR /&gt;
Females&lt;BR /&gt;
A   B   C   D   E   F&lt;BR /&gt;
1    F        F    &lt;BR /&gt;
2&lt;BR /&gt;
&lt;BR /&gt;
Males&lt;BR /&gt;
A   B   C  D   E   F&lt;BR /&gt;
1    M     &lt;BR /&gt;
2&lt;BR /&gt;
&lt;BR /&gt;
Siblings&lt;BR /&gt;
A   B   C   D   E   F&lt;BR /&gt;
1   S         S&lt;BR /&gt;
2</description>
      <pubDate>Wed, 09 Mar 2011 20:06:54 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/Three-datasets-same-variables-different-values-need-to-combine/m-p/25478#M5774</guid>
      <dc:creator>deleted_user</dc:creator>
      <dc:date>2011-03-09T20:06:54Z</dc:date>
    </item>
    <item>
      <title>Re: Three datasets, same variables, different values - need to combine into one</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/Three-datasets-same-variables-different-values-need-to-combine/m-p/25479#M5775</link>
      <description>What the output of the example data look like?</description>
      <pubDate>Wed, 09 Mar 2011 20:41:48 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/Three-datasets-same-variables-different-values-need-to-combine/m-p/25479#M5775</guid>
      <dc:creator>ballardw</dc:creator>
      <dc:date>2011-03-09T20:41:48Z</dc:date>
    </item>
    <item>
      <title>Re: Three datasets, same variables, different values - need to combine into one</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/Three-datasets-same-variables-different-values-need-to-combine/m-p/25480#M5776</link>
      <description>After inputting your individual files, you can use SAS DATA step processing with the MERGE statement (possibly with a BY statement and key identification variables - maybe not?)  And with the MERGE statement, you have an IN= keyword to tell SAS to reveal what file(s) contributed to the MERGE.  Also, you must have a RENAME= on the MERGE (for each dataset to make SAS variables unique), or do so on the input side when you create the individual files.&lt;BR /&gt;
&lt;BR /&gt;
Scott Barry&lt;BR /&gt;
SBBWorks, Inc.</description>
      <pubDate>Wed, 09 Mar 2011 20:50:57 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/Three-datasets-same-variables-different-values-need-to-combine/m-p/25480#M5776</guid>
      <dc:creator>sbb</dc:creator>
      <dc:date>2011-03-09T20:50:57Z</dc:date>
    </item>
    <item>
      <title>Re: Three datasets, same variables, different values - need to combine into one</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/Three-datasets-same-variables-different-values-need-to-combine/m-p/25481#M5777</link>
      <description>Hello JHale,&lt;BR /&gt;
&lt;BR /&gt;
I am not 100% sure I understood but anyway it is a solution:&lt;BR /&gt;
[pre]&lt;BR /&gt;
data Males;&lt;BR /&gt;
input MA $ 1-1 MB $ 3-3 MC $ 5-5; &lt;BR /&gt;
datalines;&lt;BR /&gt;
1 M  &lt;BR /&gt;
run;&lt;BR /&gt;
data Females;&lt;BR /&gt;
input FA $ FB $ FC $;&lt;BR /&gt;
datalines;&lt;BR /&gt;
1 F F &lt;BR /&gt;
run;&lt;BR /&gt;
data Siblings;&lt;BR /&gt;
input SA $ SB $ SC $;&lt;BR /&gt;
datalines;&lt;BR /&gt;
1 S S&lt;BR /&gt;
run;&lt;BR /&gt;
data c;&lt;BR /&gt;
  length A B C $4;&lt;BR /&gt;
  merge Males Females Siblings;&lt;BR /&gt;
  A=" ";&lt;BR /&gt;
  if MA = "M" then A=TRIM(A)||MA;&lt;BR /&gt;
  if FA = "F" then A=TRIM(A)||FA;&lt;BR /&gt;
  if SA = "S" then A=TRIM(A)||SA;&lt;BR /&gt;
  B=" ";&lt;BR /&gt;
  if MB = "M" then B=TRIM(B)||MB;&lt;BR /&gt;
  if FB = "F" then B=TRIM(B)||FB;&lt;BR /&gt;
  if SB = "S" then B=TRIM(B)||SB;&lt;BR /&gt;
  C=" ";&lt;BR /&gt;
  if MC = "M" then C=TRIM(C)||MC;&lt;BR /&gt;
  if FC = "F" then C=TRIM(C)||FC;&lt;BR /&gt;
  if SC = "S" then C=TRIM(C)||SC;&lt;BR /&gt;
run;&lt;BR /&gt;
[/pre]&lt;BR /&gt;
Sincerely,&lt;BR /&gt;
SPR</description>
      <pubDate>Wed, 09 Mar 2011 21:26:28 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/Three-datasets-same-variables-different-values-need-to-combine/m-p/25481#M5777</guid>
      <dc:creator>SPR</dc:creator>
      <dc:date>2011-03-09T21:26:28Z</dc:date>
    </item>
    <item>
      <title>Re: Three datasets, same variables, different values - need to combine into one</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/Three-datasets-same-variables-different-values-need-to-combine/m-p/25482#M5778</link>
      <description>Assuming variable A has unique value in all three datasets.&lt;BR /&gt;
&lt;BR /&gt;
&lt;BR /&gt;
[pre]&lt;BR /&gt;
data female;&lt;BR /&gt;
 infile datalines truncover;&lt;BR /&gt;
 input a b_f $ c_f $ d_f $ e_f $ f_f $ ;&lt;BR /&gt;
datalines;&lt;BR /&gt;
1 F F&lt;BR /&gt;
2&lt;BR /&gt;
;&lt;BR /&gt;
run;&lt;BR /&gt;
data male;&lt;BR /&gt;
 infile datalines truncover;&lt;BR /&gt;
 input a b_m $ c_m $ d_m $ e_m $ f_m $ ;&lt;BR /&gt;
datalines;&lt;BR /&gt;
1 M&lt;BR /&gt;
2&lt;BR /&gt;
;&lt;BR /&gt;
run;&lt;BR /&gt;
data sibling;&lt;BR /&gt;
 infile datalines truncover;&lt;BR /&gt;
 input a b_s $ c_s $ d_s $ e_s $ f_s $ ;&lt;BR /&gt;
datalines;&lt;BR /&gt;
1 S S&lt;BR /&gt;
2&lt;BR /&gt;
;&lt;BR /&gt;
run;&lt;BR /&gt;
data want;&lt;BR /&gt;
 merge female male sibling;&lt;BR /&gt;
 by a;&lt;BR /&gt;
 length b c d e f $ 10;&lt;BR /&gt;
 b=catt(of b_:);&lt;BR /&gt;
 c=catt(of c_:);&lt;BR /&gt;
 d=catt(of d_:);&lt;BR /&gt;
 e=catt(of e_:);&lt;BR /&gt;
 f=catt(of f_:);&lt;BR /&gt;
 keep a b c d e f;&lt;BR /&gt;
run;&lt;BR /&gt;
&lt;BR /&gt;
[/pre]&lt;BR /&gt;
&lt;BR /&gt;
&lt;BR /&gt;
Ksharp</description>
      <pubDate>Thu, 10 Mar 2011 05:24:47 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/Three-datasets-same-variables-different-values-need-to-combine/m-p/25482#M5778</guid>
      <dc:creator>Ksharp</dc:creator>
      <dc:date>2011-03-10T05:24:47Z</dc:date>
    </item>
  </channel>
</rss>

