<?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: Sum command for numeric variables in SAS Procedures</title>
    <link>https://communities.sas.com/t5/SAS-Procedures/Sum-command-for-numeric-variables/m-p/434317#M68875</link>
    <description>&lt;P&gt;Thank you for taking the time to respond to my message. I made a mistake in another part of my code, and that was why the sum command wasn't working as intended. I didn't want to post the entire code because I thought it was too long. Next time I will make sure to post everything.&lt;/P&gt;&lt;P&gt;Thanks again&lt;/P&gt;</description>
    <pubDate>Mon, 05 Feb 2018 18:20:17 GMT</pubDate>
    <dc:creator>stickm</dc:creator>
    <dc:date>2018-02-05T18:20:17Z</dc:date>
    <item>
      <title>Sum command for numeric variables</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/Sum-command-for-numeric-variables/m-p/433850#M68829</link>
      <description>&lt;P&gt;Hello, I am trying to sum two numeric variables on SAS university.&lt;/P&gt;&lt;P&gt;I am using the code:&lt;/P&gt;&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;income= sum(FA7D, MB11D);&lt;BR /&gt;&lt;BR /&gt;run;&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;However, the results are not summing the numeric variables. I used the&lt;/P&gt;&lt;P&gt;proc print; command for my variables and this is what I am seeing...&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="Capture.JPG" style="width: 289px;"&gt;&lt;img src="https://communities.sas.com/t5/image/serverpage/image-id/18297iF0E8EC4B5FE1C5EE/image-size/large?v=v2&amp;amp;px=999" role="button" title="Capture.JPG" alt="Capture.JPG" /&gt;&lt;/span&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Can anyone please tell me what I am doing wrong?&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Thanks,&lt;/P&gt;</description>
      <pubDate>Sat, 03 Feb 2018 20:30:21 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/Sum-command-for-numeric-variables/m-p/433850#M68829</guid>
      <dc:creator>stickm</dc:creator>
      <dc:date>2018-02-03T20:30:21Z</dc:date>
    </item>
    <item>
      <title>Re: Sum command for numeric variables</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/Sum-command-for-numeric-variables/m-p/433862#M68831</link>
      <description>&lt;P&gt;If you have N in your data your variables may not be numeric.&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;If you're trying to get the sum of a column the SUM() function isn't correct, that calculates the SUM for a specific row.&amp;nbsp;&lt;/P&gt;
&lt;P&gt;If you're trying to get the sum of a column use a Summary PROC such as PROC MEANS, SUMMARY or UNIVARIATE for starters.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Video tutorials are here:&lt;/P&gt;
&lt;P&gt;&lt;A href="http://video.sas.com" target="_self"&gt;video.sas.com&amp;nbsp;&lt;/A&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;And specifically calculating summary statistics is&amp;nbsp;here:&lt;/P&gt;
&lt;P&gt;&lt;A href="http://video.sas.com/detail/videos/sas-analytics-u/video/3306906230001/summary-statistics-using-sas-studio?autoStart=true&amp;amp;page=1" target="_blank"&gt;http://video.sas.com/detail/videos/sas-analytics-u/video/3306906230001/summary-statistics-using-sas-studio?autoStart=true&amp;amp;page=1&lt;/A&gt;&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/191210"&gt;@stickm&lt;/a&gt; wrote:&lt;BR /&gt;
&lt;P&gt;Hello, I am trying to sum two numeric variables on SAS university.&lt;/P&gt;
&lt;P&gt;I am using the code:&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;income= sum(FA7D, MB11D);&lt;BR /&gt;&lt;BR /&gt;run;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;However, the results are not summing the numeric variables. I used the&lt;/P&gt;
&lt;P&gt;proc print; command for my variables and this is what I am seeing...&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="Capture.JPG" style="width: 289px;"&gt;&lt;img src="https://communities.sas.com/t5/image/serverpage/image-id/18297iF0E8EC4B5FE1C5EE/image-size/large?v=v2&amp;amp;px=999" role="button" title="Capture.JPG" alt="Capture.JPG" /&gt;&lt;/span&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Can anyone please tell me what I am doing wrong?&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Thanks,&lt;/P&gt;
&lt;HR /&gt;&lt;/BLOCKQUOTE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Sat, 03 Feb 2018 20:46:18 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/Sum-command-for-numeric-variables/m-p/433862#M68831</guid>
      <dc:creator>Reeza</dc:creator>
      <dc:date>2018-02-03T20:46:18Z</dc:date>
    </item>
    <item>
      <title>Re: Sum command for numeric variables</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/Sum-command-for-numeric-variables/m-p/433869#M68832</link>
      <description>&lt;P&gt;Thank you for the quick reply.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I believe both variables are numeric. When I used the&amp;nbsp;&lt;/P&gt;&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;proc contents;&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;function it showed me:&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="1.JPG" style="width: 600px;"&gt;&lt;img src="https://communities.sas.com/t5/image/serverpage/image-id/18298i440CE2D97248DB95/image-size/large?v=v2&amp;amp;px=999" role="button" title="1.JPG" alt="1.JPG" /&gt;&lt;/span&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="2.JPG" style="width: 579px;"&gt;&lt;img src="https://communities.sas.com/t5/image/serverpage/image-id/18299iC7C3E03B8FC2F477/image-size/large?v=v2&amp;amp;px=999" role="button" title="2.JPG" alt="2.JPG" /&gt;&lt;/span&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I am trying to create a new variable that combines the total value in each row for FA7D and MB11D.&lt;/P&gt;&lt;P&gt;Everything resource I have found has told me to use the newvariable=sum(var1, var2) command. However, when I perform it, it doesn't sum the values. It shows the new variable value as missing instead of being summed.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Thanks again,&lt;/P&gt;</description>
      <pubDate>Sat, 03 Feb 2018 21:02:09 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/Sum-command-for-numeric-variables/m-p/433869#M68832</guid>
      <dc:creator>stickm</dc:creator>
      <dc:date>2018-02-03T21:02:09Z</dc:date>
    </item>
    <item>
      <title>Re: Sum command for numeric variables</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/Sum-command-for-numeric-variables/m-p/433874#M68833</link>
      <description>&lt;P&gt;Is you use of the SUM function embedded in a condition step of your logic, i.e. in an "if" statement &amp;nbsp;&amp;nbsp; or a do group triggered by an if statement?&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Show us the log for a more precise answer.&lt;/P&gt;</description>
      <pubDate>Sat, 03 Feb 2018 21:10:37 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/Sum-command-for-numeric-variables/m-p/433874#M68833</guid>
      <dc:creator>mkeintz</dc:creator>
      <dc:date>2018-02-03T21:10:37Z</dc:date>
    </item>
    <item>
      <title>Re: Sum command for numeric variables</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/Sum-command-for-numeric-variables/m-p/433875#M68834</link>
      <description>&lt;P&gt;I doubt if anyone can help unless you show the entire datastep you ran and post your dataset (not a picture of it)&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Art, CEO, AnalystFinder.com&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Sat, 03 Feb 2018 21:10:58 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/Sum-command-for-numeric-variables/m-p/433875#M68834</guid>
      <dc:creator>art297</dc:creator>
      <dc:date>2018-02-03T21:10:58Z</dc:date>
    </item>
    <item>
      <title>Re: Sum command for numeric variables</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/Sum-command-for-numeric-variables/m-p/433877#M68835</link>
      <description>&lt;P&gt;Post the full log of the run. I belirve the hint is there.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;There is no syntax error in your code&amp;nbsp;&lt;STRONG&gt;income = sum(FA7D, MB11D);&lt;/STRONG&gt;&lt;/P&gt;</description>
      <pubDate>Sat, 03 Feb 2018 21:19:31 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/Sum-command-for-numeric-variables/m-p/433877#M68835</guid>
      <dc:creator>Shmuel</dc:creator>
      <dc:date>2018-02-03T21:19:31Z</dc:date>
    </item>
    <item>
      <title>Re: Sum command for numeric variables</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/Sum-command-for-numeric-variables/m-p/434246#M68872</link>
      <description>&lt;P&gt;Show your entire code. I do NOT believe that is only the result for the code snippet you have shown as SAS will convert character values to numeric and sum the result.&lt;/P&gt;
&lt;P&gt;Example:&lt;/P&gt;
&lt;PRE&gt;data junk;
   input x $ y $;
   z = sum(x,y);
datalines;
1 2
N 3
4 5
6 N
;
proc print;
run;&lt;/PRE&gt;
&lt;P&gt;There will be notes in the log like:&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;NOTE: Character values have been converted to numeric values at the places given by:
      (Line):(Column).
&lt;/PRE&gt;
&lt;P&gt;saying the character variables were treated as numeric.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;If the variables are truly numeric the only way to have N displayed would be to have the special missing .N (yes there is a period preceding the N) and the SUM will still work. HOWEVER if you used income = FA7D + MB11D; That would generate the output you show for Proc Print.&lt;/P&gt;
&lt;P&gt;Perhaps the data step you used SUM in had another error and did not replace a data set created with the + sum for some reason. Which is why we say : Show the log of the data step with any messages. Paste into a code box opened with the forum {I} icon to preserve formatting of any error or warning messages.&lt;/P&gt;</description>
      <pubDate>Mon, 05 Feb 2018 16:40:34 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/Sum-command-for-numeric-variables/m-p/434246#M68872</guid>
      <dc:creator>ballardw</dc:creator>
      <dc:date>2018-02-05T16:40:34Z</dc:date>
    </item>
    <item>
      <title>Re: Sum command for numeric variables</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/Sum-command-for-numeric-variables/m-p/434317#M68875</link>
      <description>&lt;P&gt;Thank you for taking the time to respond to my message. I made a mistake in another part of my code, and that was why the sum command wasn't working as intended. I didn't want to post the entire code because I thought it was too long. Next time I will make sure to post everything.&lt;/P&gt;&lt;P&gt;Thanks again&lt;/P&gt;</description>
      <pubDate>Mon, 05 Feb 2018 18:20:17 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/Sum-command-for-numeric-variables/m-p/434317#M68875</guid>
      <dc:creator>stickm</dc:creator>
      <dc:date>2018-02-05T18:20:17Z</dc:date>
    </item>
    <item>
      <title>Re: Sum command for numeric variables</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/Sum-command-for-numeric-variables/m-p/434320#M68876</link>
      <description>&lt;P&gt;Please mark this as resolved, you can use your last post as the correct solution.&lt;/P&gt;</description>
      <pubDate>Mon, 05 Feb 2018 18:24:47 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/Sum-command-for-numeric-variables/m-p/434320#M68876</guid>
      <dc:creator>Reeza</dc:creator>
      <dc:date>2018-02-05T18:24:47Z</dc:date>
    </item>
  </channel>
</rss>

