<?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 to have just one for each ID in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/combine-observations-to-have-just-one-for-each-ID/m-p/862001#M340467</link>
    <description>&lt;P&gt;If ignoring Code.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;proc means data=sashelp.cars nway noprint;
class origin;
output out=want mean(mpg_city mpg_highway) =  max(cylinders msrp) = ;
run;

proc print data=want;
run;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;List variables in Mean/max as desired for each statistic.&amp;nbsp;&lt;/P&gt;</description>
    <pubDate>Thu, 02 Mar 2023 19:01:35 GMT</pubDate>
    <dc:creator>Reeza</dc:creator>
    <dc:date>2023-03-02T19:01:35Z</dc:date>
    <item>
      <title>combine observations to have just one for each ID</title>
      <link>https://communities.sas.com/t5/SAS-Programming/combine-observations-to-have-just-one-for-each-ID/m-p/861997#M340463</link>
      <description>&lt;P&gt;This is my data (below). The ID is not unique, so I want to combine the repeated observations into one. In the example there are just 2 variables (revenues and assets). My dataset has 50. I want to combine by choosing the either the average of both values, or the max of the two values. The goal is to have one observation for each ID. How can I efficiently do this for all 50 variables?&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;PRE&gt;&lt;CODE class=""&gt;data have;
input Obs ID $12. code $ revenues $10. assets $10. ;
cards;
1 AC0000037163 C1 3500 6000
2 AC0000037163 C1 3470 6020
3 BE0000037282 U2 9350 21930
4 BE0000037282 U2 13001 18549
5 CZ0000037693 C1 32010 45010
6 CZ0000037693 C2 27981 59082
7 FR0000037738 U1 1237 4392
8 FR0000037738 U1 11000 24800
;&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Thu, 02 Mar 2023 18:50:33 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/combine-observations-to-have-just-one-for-each-ID/m-p/861997#M340463</guid>
      <dc:creator>Satori</dc:creator>
      <dc:date>2023-03-02T18:50:33Z</dc:date>
    </item>
    <item>
      <title>Re: combine observations to have just one for each ID</title>
      <link>https://communities.sas.com/t5/SAS-Programming/combine-observations-to-have-just-one-for-each-ID/m-p/861999#M340465</link>
      <description>&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;proc summary data=have nway;
    class id;
    var revenues--last_variable_name;&lt;BR /&gt;    id code;
    output out=want mean=;
run;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;This computes the mean for each variable. If you want the max for each variable, change &lt;FONT face="courier new,courier"&gt;mean=&lt;/FONT&gt; to &lt;FONT face="courier new,courier"&gt;max=&lt;/FONT&gt;&lt;/P&gt;</description>
      <pubDate>Thu, 02 Mar 2023 18:58:31 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/combine-observations-to-have-just-one-for-each-ID/m-p/861999#M340465</guid>
      <dc:creator>PaigeMiller</dc:creator>
      <dc:date>2023-03-02T18:58:31Z</dc:date>
    </item>
    <item>
      <title>Re: combine observations to have just one for each ID</title>
      <link>https://communities.sas.com/t5/SAS-Programming/combine-observations-to-have-just-one-for-each-ID/m-p/862000#M340466</link>
      <description>Please show sample output. How do you want the 5/6th observations handled where the CODE is not the same?&lt;BR /&gt;&lt;BR /&gt;If you can ignore the code, then look into PROC MEANS to summarize the data.</description>
      <pubDate>Thu, 02 Mar 2023 18:54:56 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/combine-observations-to-have-just-one-for-each-ID/m-p/862000#M340466</guid>
      <dc:creator>Reeza</dc:creator>
      <dc:date>2023-03-02T18:54:56Z</dc:date>
    </item>
    <item>
      <title>Re: combine observations to have just one for each ID</title>
      <link>https://communities.sas.com/t5/SAS-Programming/combine-observations-to-have-just-one-for-each-ID/m-p/862001#M340467</link>
      <description>&lt;P&gt;If ignoring Code.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;proc means data=sashelp.cars nway noprint;
class origin;
output out=want mean(mpg_city mpg_highway) =  max(cylinders msrp) = ;
run;

proc print data=want;
run;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;List variables in Mean/max as desired for each statistic.&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Thu, 02 Mar 2023 19:01:35 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/combine-observations-to-have-just-one-for-each-ID/m-p/862001#M340467</guid>
      <dc:creator>Reeza</dc:creator>
      <dc:date>2023-03-02T19:01:35Z</dc:date>
    </item>
  </channel>
</rss>

