<?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: squaring vales then adding squares by group in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/squaring-vales-then-adding-squares-by-group/m-p/957721#M373842</link>
    <description>Thank you!</description>
    <pubDate>Thu, 30 Jan 2025 20:15:49 GMT</pubDate>
    <dc:creator>Ihsan-Mahdi</dc:creator>
    <dc:date>2025-01-30T20:15:49Z</dc:date>
    <item>
      <title>squaring vales then adding squares by group</title>
      <link>https://communities.sas.com/t5/SAS-Programming/squaring-vales-then-adding-squares-by-group/m-p/957710#M373838</link>
      <description>&lt;P&gt;Hello,&lt;/P&gt;
&lt;P&gt;I have a data set that looks something like this:&lt;/P&gt;
&lt;P&gt;DATA example;&lt;BR /&gt;INPUT id ais;&lt;BR /&gt;DATALINES;&lt;BR /&gt;1 3&lt;BR /&gt;1 4&lt;BR /&gt;2 5&lt;BR /&gt;2 7&lt;BR /&gt;2 3&lt;BR /&gt;3 2&lt;BR /&gt;3 4&lt;BR /&gt;3 1&lt;BR /&gt;;&lt;BR /&gt;run;&lt;/P&gt;
&lt;P&gt;I would like to square each "ais" value, then add the squares by each "id" value creating a new variable called "iss".&lt;/P&gt;
&lt;P&gt;so for "id" (1) the iss should equal 9+16=25.&lt;/P&gt;
&lt;P&gt;I tried different codes but none worked. Help please!&lt;/P&gt;</description>
      <pubDate>Thu, 30 Jan 2025 19:20:25 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/squaring-vales-then-adding-squares-by-group/m-p/957710#M373838</guid>
      <dc:creator>Ihsan-Mahdi</dc:creator>
      <dc:date>2025-01-30T19:20:25Z</dc:date>
    </item>
    <item>
      <title>Re: squaring vales then adding squares by group</title>
      <link>https://communities.sas.com/t5/SAS-Programming/squaring-vales-then-adding-squares-by-group/m-p/957718#M373840</link>
      <description>&lt;P&gt;This is a job for PROC SUMMARY. No need to write your own DATA step code with a mathematical formula.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;proc summary data=example nway;
    class id;
    var ais;
    output out=want uss=sum_of_squares;
run;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Thu, 30 Jan 2025 20:05:05 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/squaring-vales-then-adding-squares-by-group/m-p/957718#M373840</guid>
      <dc:creator>PaigeMiller</dc:creator>
      <dc:date>2025-01-30T20:05:05Z</dc:date>
    </item>
    <item>
      <title>Re: squaring vales then adding squares by group</title>
      <link>https://communities.sas.com/t5/SAS-Programming/squaring-vales-then-adding-squares-by-group/m-p/957719#M373841</link>
      <description>&lt;P&gt;Assuming you want to output 3 observations, one per BY group, then something like this should do the job.&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data want;
  do until(last.id);
    set example;
    by id;
    iss = sum(iss,ais**2);
  end;
  keep id iss;
run;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Thu, 30 Jan 2025 20:04:54 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/squaring-vales-then-adding-squares-by-group/m-p/957719#M373841</guid>
      <dc:creator>Tom</dc:creator>
      <dc:date>2025-01-30T20:04:54Z</dc:date>
    </item>
    <item>
      <title>Re: squaring vales then adding squares by group</title>
      <link>https://communities.sas.com/t5/SAS-Programming/squaring-vales-then-adding-squares-by-group/m-p/957721#M373842</link>
      <description>Thank you!</description>
      <pubDate>Thu, 30 Jan 2025 20:15:49 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/squaring-vales-then-adding-squares-by-group/m-p/957721#M373842</guid>
      <dc:creator>Ihsan-Mahdi</dc:creator>
      <dc:date>2025-01-30T20:15:49Z</dc:date>
    </item>
  </channel>
</rss>

