<?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 can I compare variables from different tables? in SAS Procedures</title>
    <link>https://communities.sas.com/t5/SAS-Procedures/How-can-I-compare-variables-from-different-tables/m-p/561777#M74913</link>
    <description>That's the exact same thing, you just used a different word that included/excluded. &lt;BR /&gt;&lt;BR /&gt;I preferred the words since that goes as labels for output &lt;span class="lia-unicode-emoji" title=":winking_face:"&gt;😉&lt;/span&gt;</description>
    <pubDate>Mon, 27 May 2019 17:59:37 GMT</pubDate>
    <dc:creator>Reeza</dc:creator>
    <dc:date>2019-05-27T17:59:37Z</dc:date>
    <item>
      <title>How can I compare variables from different tables?</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/How-can-I-compare-variables-from-different-tables/m-p/561747#M74909</link>
      <description>&lt;P&gt;Hi,&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I would like to compare the sociodemographic characteristics (mean age, bmi, education distribution, etc.) between individuals included and excluded (due to aberrant/missing data) from my analysis.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I have a table "included" with around 43k individuals and a table "excluded" with around 5k individuals.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;How should I proceed?&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Thank you in advance,&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Natasha Figueiredo&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Mon, 27 May 2019 13:15:47 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/How-can-I-compare-variables-from-different-tables/m-p/561747#M74909</guid>
      <dc:creator>natasha_nf</dc:creator>
      <dc:date>2019-05-27T13:15:47Z</dc:date>
    </item>
    <item>
      <title>Re: How can I compare variables from different tables?</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/How-can-I-compare-variables-from-different-tables/m-p/561749#M74910</link>
      <description>&lt;P&gt;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/259641"&gt;@natasha_nf&lt;/a&gt; see if this information assist you in how to prepare data for usage with proc compare.&lt;/P&gt;
&lt;P&gt;&lt;FONT style="background-color: #ffffff;"&gt;&lt;A href="https://www.sascrunch.com/proc-compare.html" target="_blank"&gt;https://www.sascrunch.com/proc-compare.html&lt;/A&gt;&lt;/FONT&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Mon, 27 May 2019 13:27:31 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/How-can-I-compare-variables-from-different-tables/m-p/561749#M74910</guid>
      <dc:creator>VDD</dc:creator>
      <dc:date>2019-05-27T13:27:31Z</dc:date>
    </item>
    <item>
      <title>Re: How can I compare variables from different tables?</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/How-can-I-compare-variables-from-different-tables/m-p/561762#M74911</link>
      <description>&lt;P&gt;PROC COMPARE is not what is needed here. You aren't comparing line by line records, you're comparing statistical distributions and such. Usually the standard is to do t-tests and chi-square tests depending on the variable types.&amp;nbsp;&lt;/P&gt;
&lt;P&gt;It's usually easier if you include them in the same data set.&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;I would stack the data sets as follows:&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data combined;

set included (in=A)
      excluded (in=B);
length status $12.;

status='Included';

if B then status='Excluded';

run;


*tests if age is the same across the two groups;
proc ttest data=combined;
class included;
var age;
run;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Hope that helps get you started.&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/259641"&gt;@natasha_nf&lt;/a&gt;&amp;nbsp;wrote:&lt;BR /&gt;
&lt;P&gt;Hi,&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;I would like to compare the sociodemographic characteristics (mean age, bmi, education distribution, etc.) between individuals included and excluded (due to aberrant/missing data) from my analysis.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;I have a table "included" with around 43k individuals and a table "excluded" with around 5k individuals.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;How should I proceed?&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Thank you in advance,&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Natasha Figueiredo&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, 27 May 2019 15:16:15 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/How-can-I-compare-variables-from-different-tables/m-p/561762#M74911</guid>
      <dc:creator>Reeza</dc:creator>
      <dc:date>2019-05-27T15:16:15Z</dc:date>
    </item>
    <item>
      <title>Re: How can I compare variables from different tables?</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/How-can-I-compare-variables-from-different-tables/m-p/561763#M74912</link>
      <description>&lt;P&gt;Thank you Reeza!&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Actually I've done something &lt;SPAN class="ILfuVd"&gt;&lt;SPAN class="e24Kjd"&gt;slightly &lt;/SPAN&gt;&lt;/SPAN&gt;different. I merged the original (with all included and excluded individuals) and the "excluded" tables and created a binary "included" variable.&lt;/P&gt;&lt;P&gt;&lt;BR /&gt;data incexc;&lt;BR /&gt;merge original (in=a) excluded (in=b);&lt;BR /&gt;if a and not b then included='1';&lt;BR /&gt;else included='0';&lt;BR /&gt;run;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Then I performed all the t and x2 tests I needed.&lt;/P&gt;</description>
      <pubDate>Mon, 27 May 2019 15:27:49 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/How-can-I-compare-variables-from-different-tables/m-p/561763#M74912</guid>
      <dc:creator>natasha_nf</dc:creator>
      <dc:date>2019-05-27T15:27:49Z</dc:date>
    </item>
    <item>
      <title>Re: How can I compare variables from different tables?</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/How-can-I-compare-variables-from-different-tables/m-p/561777#M74913</link>
      <description>That's the exact same thing, you just used a different word that included/excluded. &lt;BR /&gt;&lt;BR /&gt;I preferred the words since that goes as labels for output &lt;span class="lia-unicode-emoji" title=":winking_face:"&gt;😉&lt;/span&gt;</description>
      <pubDate>Mon, 27 May 2019 17:59:37 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/How-can-I-compare-variables-from-different-tables/m-p/561777#M74913</guid>
      <dc:creator>Reeza</dc:creator>
      <dc:date>2019-05-27T17:59:37Z</dc:date>
    </item>
    <item>
      <title>Re: How can I compare variables from different tables?</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/How-can-I-compare-variables-from-different-tables/m-p/561780#M74914</link>
      <description>&lt;BLOCKQUOTE&gt;&lt;HR /&gt;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/259641"&gt;@natasha_nf&lt;/a&gt;&amp;nbsp;wrote:&lt;BR /&gt;
&lt;P&gt;Thank you Reeza!&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Actually I've done something &lt;SPAN class="ILfuVd"&gt;&lt;SPAN class="e24Kjd"&gt;slightly &lt;/SPAN&gt;&lt;/SPAN&gt;different. I merged the original (with all included and excluded individuals) and the "excluded" tables and created a binary "included" variable.&lt;/P&gt;
&lt;P&gt;&lt;BR /&gt;data incexc;&lt;BR /&gt;merge original (in=a) excluded (in=b);&lt;BR /&gt;if a and not b then included='1';&lt;BR /&gt;else included='0';&lt;BR /&gt;run;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Then I performed all the t and x2 tests I needed.&lt;/P&gt;
&lt;HR /&gt;&lt;/BLOCKQUOTE&gt;
&lt;P&gt;How could that MERGE work?&amp;nbsp; You did not include a BY variable.&amp;nbsp; So if ORIGINAL has 100 observations and EXCLUDED as 50 observations then the first 50 observations will be FROM both input datasets (A and B) and the last 50 will only be from the ORIGINAL dataset.&amp;nbsp; Is your ORIGINAL dataset really sorted so that all of the EXCLUDED observations are first?&amp;nbsp; Are they in the same order as the observations in EXCLUDED?&amp;nbsp; If not the the values of the common variables will be overwritten with the values from EXCLUDED dataset.&lt;/P&gt;</description>
      <pubDate>Mon, 27 May 2019 18:11:26 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/How-can-I-compare-variables-from-different-tables/m-p/561780#M74914</guid>
      <dc:creator>Tom</dc:creator>
      <dc:date>2019-05-27T18:11:26Z</dc:date>
    </item>
    <item>
      <title>Re: How can I compare variables from different tables?</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/How-can-I-compare-variables-from-different-tables/m-p/561879#M74915</link>
      <description>&lt;P&gt;Hi Tom,&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I must admit I don't really see what you mean, I'm sorry.&lt;/P&gt;&lt;P&gt;Anyway, I included the by ID variable and indeed, it changed the order the dataset is sorted. However, I did not affect my tests.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Thank you&lt;/P&gt;</description>
      <pubDate>Tue, 28 May 2019 09:34:05 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/How-can-I-compare-variables-from-different-tables/m-p/561879#M74915</guid>
      <dc:creator>natasha_nf</dc:creator>
      <dc:date>2019-05-28T09:34:05Z</dc:date>
    </item>
    <item>
      <title>Re: How can I compare variables from different tables?</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/How-can-I-compare-variables-from-different-tables/m-p/561956#M74918</link>
      <description>&lt;BLOCKQUOTE&gt;&lt;HR /&gt;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/259641"&gt;@natasha_nf&lt;/a&gt;&amp;nbsp;wrote:&lt;BR /&gt;
&lt;P&gt;Hi Tom,&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;I must admit I don't really see what you mean, I'm sorry.&lt;/P&gt;
&lt;P&gt;Anyway, I included the by ID variable and indeed, it changed the order the dataset is sorted. However, I did not affect my tests.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Thank you&lt;/P&gt;
&lt;HR /&gt;&lt;/BLOCKQUOTE&gt;
&lt;P&gt;To see the potential havoc of merging without a BY statement run this example and look at the the differences in the TEST1 and TEST2 datasets.&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data original excluded ;
 set sashelp.class ;
 output original;
 if sex='M' then output excluded;
run;

data test1;
  merge original(in=in1) excluded(in=in2);
  excluded=in2;
run;

data test2;
  merge original(in=in1) excluded(in=in2);
  by name;
  excluded=in2;
run;
&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Tue, 28 May 2019 13:11:12 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/How-can-I-compare-variables-from-different-tables/m-p/561956#M74918</guid>
      <dc:creator>Tom</dc:creator>
      <dc:date>2019-05-28T13:11:12Z</dc:date>
    </item>
  </channel>
</rss>

