<?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 dividing 2 sum_values in SAS Procedures</title>
    <link>https://communities.sas.com/t5/SAS-Procedures/dividing-2-sum-values/m-p/30056#M7080</link>
    <description>Is is possible to divide 2 sum_values together accurately? I am aware that the sum values will carry over, and that is why so far I am not getting the correct answer, is there another function I can use to divide 2 sum_values?</description>
    <pubDate>Tue, 15 Mar 2011 16:26:38 GMT</pubDate>
    <dc:creator>deleted_user</dc:creator>
    <dc:date>2011-03-15T16:26:38Z</dc:date>
    <item>
      <title>dividing 2 sum_values</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/dividing-2-sum-values/m-p/30056#M7080</link>
      <description>Is is possible to divide 2 sum_values together accurately? I am aware that the sum values will carry over, and that is why so far I am not getting the correct answer, is there another function I can use to divide 2 sum_values?</description>
      <pubDate>Tue, 15 Mar 2011 16:26:38 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/dividing-2-sum-values/m-p/30056#M7080</guid>
      <dc:creator>deleted_user</dc:creator>
      <dc:date>2011-03-15T16:26:38Z</dc:date>
    </item>
    <item>
      <title>Re: dividing 2 sum_values</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/dividing-2-sum-values/m-p/30057#M7081</link>
      <description>Please be more clear.  Are you in a procedure, datastep, proc report?</description>
      <pubDate>Tue, 15 Mar 2011 21:38:07 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/dividing-2-sum-values/m-p/30057#M7081</guid>
      <dc:creator>CurtisMack</dc:creator>
      <dc:date>2011-03-15T21:38:07Z</dc:date>
    </item>
    <item>
      <title>Re: dividing 2 sum_values</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/dividing-2-sum-values/m-p/30058#M7082</link>
      <description>Here is the code I have written, detailing where I am running into problems,&lt;BR /&gt;
&lt;BR /&gt;
/** combine two age groups and calculate the percentage of the poverty level with the same data set**/&lt;BR /&gt;
data pov4;&lt;BR /&gt;
set pov;&lt;BR /&gt;
if age = 'under12' or age = 'under18' then sum_value + fpl100;&lt;BR /&gt;
run;&lt;BR /&gt;
proc print data = pov4;&lt;BR /&gt;
title '5-18fpl100test';&lt;BR /&gt;
run; &lt;BR /&gt;
/**this is the part that the sum is coming up incorrect**/&lt;BR /&gt;
data pov5;&lt;BR /&gt;
set pov4;&lt;BR /&gt;
if age = 'under12' or age = 'under18' then sum_value + total;&lt;BR /&gt;
run;&lt;BR /&gt;
proc print data = pov5;&lt;BR /&gt;
title 'sumtotalof5-18poptest';&lt;BR /&gt;
run;&lt;BR /&gt;
data pov6;&lt;BR /&gt;
set pov5;&lt;BR /&gt;
percent = sum_value + fpl100 / sum_value + total * 100;&lt;BR /&gt;
run;&lt;BR /&gt;
proc print data = pov6;&lt;BR /&gt;
title 'percentage of 5-17fpl100';&lt;BR /&gt;
run;</description>
      <pubDate>Tue, 15 Mar 2011 21:58:23 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/dividing-2-sum-values/m-p/30058#M7082</guid>
      <dc:creator>deleted_user</dc:creator>
      <dc:date>2011-03-15T21:58:23Z</dc:date>
    </item>
    <item>
      <title>Re: dividing 2 sum_values</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/dividing-2-sum-values/m-p/30059#M7083</link>
      <description>CGI,&lt;BR /&gt;
&lt;BR /&gt;
Without seeing your data, I am not sure how to answer this.  Honestly, you appear to need a class on SAS basics like the data step vector.  I am going to show you two ways to do this.  The first is similar to what you tried, the second is closer to how I would actually do it.&lt;BR /&gt;
&lt;BR /&gt;
&lt;BR /&gt;
I am assuming your data looks something like this.  However, I am sure it is much more complicated.&lt;BR /&gt;
&lt;BR /&gt;
data pov;&lt;BR /&gt;
   length age $ 7;&lt;BR /&gt;
   age = 'under05'; total = 100; fpl100 = 20; output;&lt;BR /&gt;
   age = 'under12'; total = 300; fpl100 = 50; output;&lt;BR /&gt;
   age = 'under18'; total = 250; fpl100 = 60; output;&lt;BR /&gt;
   age = 'under40'; total = 1000; fpl100 = 100; output;&lt;BR /&gt;
run;&lt;BR /&gt;
&lt;BR /&gt;
Here is how I &lt;U&gt;wouldn't do it&lt;/U&gt; because it assumes a lot, particularly that there are no values of age that will sort in between under12 and under18.  I am showing it because it only uses the SAS techniques you were using.&lt;BR /&gt;
&lt;BR /&gt;
proc sort data=pov;&lt;BR /&gt;
  by age;&lt;BR /&gt;
run;&lt;BR /&gt;
&lt;BR /&gt;
data pov5b(drop = fpl100 total) ;&lt;BR /&gt;
  set pov;&lt;BR /&gt;
  retain sum_fpl100 sum_total;&lt;BR /&gt;
  sum_fpl100 = sum(sum_fpl100,fpl100);&lt;BR /&gt;
  sum_total = sum(sum_total,total);&lt;BR /&gt;
  if age ne 'under12' then do;&lt;BR /&gt;
    if age = 'under18' then age = '5-17';&lt;BR /&gt;
    percent = sum_fpl100 / sum_total;&lt;BR /&gt;
    output; &lt;BR /&gt;
    sum_fpl100 = 0;&lt;BR /&gt;
    sum_total = 0;&lt;BR /&gt;
  end;&lt;BR /&gt;
run;&lt;BR /&gt;
&lt;BR /&gt;
This is a more robust way of doing it, but it requires that you understand SAS formats and proc summary.  Note that if a format is passed a value that is it not written to handle, will return the value passed to it it.  For this reason, only the affected age categories are listed.:&lt;BR /&gt;
&lt;BR /&gt;
proc format;&lt;BR /&gt;
  value $newage &lt;BR /&gt;
    'under12' ,  'under18' = '5-18pop';&lt;BR /&gt;
run;&lt;BR /&gt;
&lt;BR /&gt;
proc summary noprint nway data=pov;&lt;BR /&gt;
  var total fpl100;&lt;BR /&gt;
  class age;&lt;BR /&gt;
  format age $newage.;&lt;BR /&gt;
  output out =  pov5 sum=;&lt;BR /&gt;
run;&lt;BR /&gt;
&lt;BR /&gt;
data pov6;&lt;BR /&gt;
  set pov5;&lt;BR /&gt;
  percent = fpl100 /  total;&lt;BR /&gt;
run;</description>
      <pubDate>Tue, 15 Mar 2011 22:48:36 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/dividing-2-sum-values/m-p/30059#M7083</guid>
      <dc:creator>CurtisMack</dc:creator>
      <dc:date>2011-03-15T22:48:36Z</dc:date>
    </item>
  </channel>
</rss>

