<?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: Combine observations with same IDs in New SAS User</title>
    <link>https://communities.sas.com/t5/New-SAS-User/Combine-observations-with-same-IDs/m-p/826706#M35295</link>
    <description>&lt;P&gt;That structure looks it would work well as a transaction file for the UPDATE statement.&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data want;
  update have(obs=0) have;
  by seq;
run;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;For UPDATE to work the ORIGINAL dataset has to have only one observation per BY group (actually a MAX of one per BY group), but the TRANSACTION dataset can have multiple observations and the transactions will be applied in order.&amp;nbsp; So the result will have the last non-missing value for each variable.&lt;/P&gt;</description>
    <pubDate>Tue, 02 Aug 2022 19:41:11 GMT</pubDate>
    <dc:creator>Tom</dc:creator>
    <dc:date>2022-08-02T19:41:11Z</dc:date>
    <item>
      <title>Combine observations with same IDs</title>
      <link>https://communities.sas.com/t5/New-SAS-User/Combine-observations-with-same-IDs/m-p/826703#M35293</link>
      <description>&lt;P&gt;Hi all,&lt;/P&gt;&lt;P&gt;I'm analyzing NHANES data and have combined day 1 food intake and day 2 food intake into their own observation rows. Now I want to combine those rows into 1 row that shows days 1 and 2 intakes for each participant. For example:&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;TABLE border="0" cellspacing="0" cellpadding="0"&gt;&lt;TBODY&gt;&lt;TR&gt;&lt;TD&gt;SEQ&lt;/TD&gt;&lt;TD&gt;DR1T_G_WHOLE&lt;/TD&gt;&lt;TD&gt;DR1T_G_REFINED&lt;/TD&gt;&lt;TD&gt;DR2T_G_WHOLE&lt;/TD&gt;&lt;TD&gt;DR2T_G_REFINED&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD&gt;1&lt;/TD&gt;&lt;TD&gt;5.2&lt;/TD&gt;&lt;TD&gt;4.01&lt;/TD&gt;&lt;TD&gt;&amp;nbsp;&lt;/TD&gt;&lt;TD&gt;&amp;nbsp;&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD&gt;1&lt;/TD&gt;&lt;TD&gt;&amp;nbsp;&lt;/TD&gt;&lt;TD&gt;&amp;nbsp;&lt;/TD&gt;&lt;TD&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; .8&lt;/TD&gt;&lt;TD&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; 1.2&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD&gt;2&lt;/TD&gt;&lt;TD&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; 1.0&lt;/TD&gt;&lt;TD&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; 2.2&lt;/TD&gt;&lt;TD&gt;&amp;nbsp;&lt;/TD&gt;&lt;TD&gt;&amp;nbsp;&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD&gt;2&lt;/TD&gt;&lt;TD&gt;&amp;nbsp;&lt;/TD&gt;&lt;TD&gt;&amp;nbsp;&lt;/TD&gt;&lt;TD&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; 2.5&lt;/TD&gt;&lt;TD&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;0&lt;/TD&gt;&lt;/TR&gt;&lt;/TBODY&gt;&lt;/TABLE&gt;&lt;P&gt;How would I combine the 1s so all the cells are filled? I also have thousands of SEQ IDs.&lt;/P&gt;&lt;P&gt;I've tried proc means data= test noprint nway;&lt;/P&gt;&lt;P&gt;class SEQ;&lt;/P&gt;&lt;P&gt;var ...;&lt;/P&gt;&lt;P&gt;output out= sums;&lt;/P&gt;&lt;P&gt;run;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;This led to a min max and std showing up as well, is there a way to remove those?&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Tue, 02 Aug 2022 19:28:11 GMT</pubDate>
      <guid>https://communities.sas.com/t5/New-SAS-User/Combine-observations-with-same-IDs/m-p/826703#M35293</guid>
      <dc:creator>kippy_kips</dc:creator>
      <dc:date>2022-08-02T19:28:11Z</dc:date>
    </item>
    <item>
      <title>Re: Combine observations with same IDs</title>
      <link>https://communities.sas.com/t5/New-SAS-User/Combine-observations-with-same-IDs/m-p/826705#M35294</link>
      <description>&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data want;
update test(obs=0) test;
by seq;
run;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;Or:&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;proc means data= test noprint nway;
class SEQ;
var _numeric_;
output out=summarized sum= ;
run;

 &lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;I think either of those approaches should work for you. But for NHANES data are there weights you need to factor in?&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Tue, 02 Aug 2022 19:38:15 GMT</pubDate>
      <guid>https://communities.sas.com/t5/New-SAS-User/Combine-observations-with-same-IDs/m-p/826705#M35294</guid>
      <dc:creator>Reeza</dc:creator>
      <dc:date>2022-08-02T19:38:15Z</dc:date>
    </item>
    <item>
      <title>Re: Combine observations with same IDs</title>
      <link>https://communities.sas.com/t5/New-SAS-User/Combine-observations-with-same-IDs/m-p/826706#M35295</link>
      <description>&lt;P&gt;That structure looks it would work well as a transaction file for the UPDATE statement.&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data want;
  update have(obs=0) have;
  by seq;
run;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;For UPDATE to work the ORIGINAL dataset has to have only one observation per BY group (actually a MAX of one per BY group), but the TRANSACTION dataset can have multiple observations and the transactions will be applied in order.&amp;nbsp; So the result will have the last non-missing value for each variable.&lt;/P&gt;</description>
      <pubDate>Tue, 02 Aug 2022 19:41:11 GMT</pubDate>
      <guid>https://communities.sas.com/t5/New-SAS-User/Combine-observations-with-same-IDs/m-p/826706#M35295</guid>
      <dc:creator>Tom</dc:creator>
      <dc:date>2022-08-02T19:41:11Z</dc:date>
    </item>
    <item>
      <title>Re: Combine observations with same IDs</title>
      <link>https://communities.sas.com/t5/New-SAS-User/Combine-observations-with-same-IDs/m-p/826715#M35299</link>
      <description>&lt;P&gt;Thank you! The first code you sent kept deleting all observations for some reason but the second one worked! I am just interested in the food groups eaten by participants for right now.&lt;/P&gt;</description>
      <pubDate>Tue, 02 Aug 2022 20:38:42 GMT</pubDate>
      <guid>https://communities.sas.com/t5/New-SAS-User/Combine-observations-with-same-IDs/m-p/826715#M35299</guid>
      <dc:creator>kippy_kips</dc:creator>
      <dc:date>2022-08-02T20:38:42Z</dc:date>
    </item>
  </channel>
</rss>

