<?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: Summing all numeric variables (flexible names and amount of variables) in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/Summing-all-numeric-variables-flexible-names-and-amount-of/m-p/27340#M4986</link>
    <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;I like the improved usability of using a single parameter to specify the dataset name versus separate libname and membername fields.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;UL&gt;&lt;LI&gt;You are testing the value of the parameters before you have protected them with quoting functions.&lt;/LI&gt;&lt;LI&gt;You should check all of the parameters you can before bailing out.&lt;/LI&gt;&lt;LI&gt;You might want to test for existence of the input dataset.&lt;/LI&gt;&lt;LI&gt;You might want to exclude &amp;amp;SUMVAR from the list of variables to include in the sum.&lt;/LI&gt;&lt;LI&gt;For even more usability you can establish defaults for some parameters.&amp;nbsp; To me the only required parameter here is the target variable name.&amp;nbsp; The default to the input dataset could be &amp;amp;syslast.&amp;nbsp; The default for the output dataset could be null string so that SAS will create DATAnn where nn is the next number after the last DATAnn that it created.&lt;/LI&gt;&lt;/UL&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
    <pubDate>Tue, 11 Oct 2011 22:27:25 GMT</pubDate>
    <dc:creator>Tom</dc:creator>
    <dc:date>2011-10-11T22:27:25Z</dc:date>
    <item>
      <title>Summing all numeric variables (flexible names and amount of variables)</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Summing-all-numeric-variables-flexible-names-and-amount-of/m-p/27326#M4972</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hello, everybody!&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;I have a program which generates a data set with one character variable and several numeric variables from data values with proc transpose. After that I need to add a variable to my data set which is equal to the sum of all these generated variables. The problem is that the names and amount of these variables are always different and I cant't get how to make SAS sum them &lt;img id="smileyhappy" class="emoticon emoticon-smileyhappy" src="https://communities.sas.com/i/smilies/16x16_smiley-happy.png" alt="Smiley Happy" title="Smiley Happy" /&gt; I was googling all the evening long but haven't found the solution &lt;img id="smileysad" class="emoticon emoticon-smileysad" src="https://communities.sas.com/i/smilies/16x16_smiley-sad.png" alt="Smiley Sad" title="Smiley Sad" /&gt; &lt;/P&gt;&lt;P&gt;Your help would be highly appreciated!&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;P.S. This is my first post here, so, please, be patient if I I posted my question in the wrong place or if the solution seems obvious for you, I am just learning SAS &lt;img id="smileyhappy" class="emoticon emoticon-smileyhappy" src="https://communities.sas.com/i/smilies/16x16_smiley-happy.png" alt="Smiley Happy" title="Smiley Happy" /&gt;&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Mon, 10 Oct 2011 19:14:27 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Summing-all-numeric-variables-flexible-names-and-amount-of/m-p/27326#M4972</guid>
      <dc:creator>Quadraaa</dc:creator>
      <dc:date>2011-10-10T19:14:27Z</dc:date>
    </item>
    <item>
      <title>Summing all numeric variables (flexible names and amount of variables)</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Summing-all-numeric-variables-flexible-names-and-amount-of/m-p/27327#M4973</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;data want;&lt;/P&gt;&lt;P&gt; set have;&lt;/P&gt;&lt;P&gt;&amp;nbsp; total = sum(of _numeric_);&lt;/P&gt;&lt;P&gt;run;&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Mon, 10 Oct 2011 19:18:44 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Summing-all-numeric-variables-flexible-names-and-amount-of/m-p/27327#M4973</guid>
      <dc:creator>Tom</dc:creator>
      <dc:date>2011-10-10T19:18:44Z</dc:date>
    </item>
    <item>
      <title>Re: Summing all numeric variables (flexible names and amount of variables)</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Summing-all-numeric-variables-flexible-names-and-amount-of/m-p/27328#M4974</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;PRE __jive_macro_name="quote" class="jive_text_macro jive_macro_quote"&gt;&lt;P&gt;Tom wrote:&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;data want;&lt;/P&gt;&lt;P&gt;set have;&lt;/P&gt;&lt;P&gt;&amp;nbsp; total = sum(of _numeric_);&lt;/P&gt;&lt;P&gt;run;&lt;/P&gt;&lt;/PRE&gt;&lt;P&gt;&lt;BR /&gt;It should be noted that with this syntax TOTAL will also appear on the RIGHT and will be summed.&amp;nbsp; Of course in this example the value is always missing when the sums take place so all is well.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;However, there could be problems with other functions particularly NMISS.&amp;nbsp; It might be prudent to make a more carefully defined list.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;I like to use arrays to create lists where I have more control of the elements, consider this example.&amp;nbsp; Using the unexecuted SET is unnecessary but illustrates a more general solution where the list is derived in a more complex way.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;PRE __default_attr="plain" __jive_macro_name="code" class="jive_text_macro jive_macro_code"&gt;&lt;P&gt;&lt;STRONG style="color: navy; font-size: 10pt; background-color: white; font-family: 'Courier New';"&gt;data&lt;/STRONG&gt;&lt;SPAN style="font-size: 10pt; color: black; font-family: 'Courier New'; background-color: white;"&gt; class;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp; &lt;SPAN style="font-size: 10pt; color: blue; font-family: 'Courier New'; background-color: white;"&gt;if&lt;/SPAN&gt; &lt;STRONG style="color: teal; font-size: 10pt; background-color: white; font-family: 'Courier New';"&gt;0&lt;/STRONG&gt; &lt;SPAN style="font-size: 10pt; color: blue; font-family: 'Courier New'; background-color: white;"&gt;then&lt;/SPAN&gt; &lt;SPAN style="font-size: 10pt; color: blue; font-family: 'Courier New'; background-color: white;"&gt;set&lt;/SPAN&gt;&lt;SPAN style="font-size: 10pt; color: black; font-family: 'Courier New'; background-color: white;"&gt; sashelp.class(keep=_numeric_);&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp; &lt;SPAN style="font-size: 10pt; color: blue; font-family: 'Courier New'; background-color: white;"&gt;array&lt;/SPAN&gt;&lt;SPAN style="font-size: 10pt; color: black; font-family: 'Courier New'; background-color: white;"&gt; v&lt;LI&gt; &lt;/LI&gt;&lt;/SPAN&gt;&lt;SPAN style="font-size: 10pt; color: blue; font-family: 'Courier New'; background-color: white;"&gt;_numeric_&lt;/SPAN&gt;&lt;SPAN style="font-size: 10pt; color: black; font-family: 'Courier New'; background-color: white;"&gt;;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp; &lt;SPAN style="font-size: 10pt; color: blue; font-family: 'Courier New'; background-color: white;"&gt;set&lt;/SPAN&gt;&lt;SPAN style="font-size: 10pt; color: black; font-family: 'Courier New'; background-color: white;"&gt; sashelp.class;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-size: 10pt; color: black; font-family: 'Courier New'; background-color: white;"&gt;&amp;nbsp;&amp;nbsp; nmiss1 = nmiss(of _numeric_);&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-size: 10pt; color: black; font-family: 'Courier New'; background-color: white;"&gt;&amp;nbsp;&amp;nbsp; nmiss2 = nmiss(of v&lt;LI&gt;);&lt;/LI&gt;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-size: 10pt; color: black; font-family: 'Courier New'; background-color: white;"&gt;&amp;nbsp;&amp;nbsp; sum&amp;nbsp;&amp;nbsp;&amp;nbsp; = sum(of v&lt;LI&gt;);&lt;/LI&gt;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-size: 10pt; color: black; font-family: 'Courier New'; background-color: white;"&gt;&amp;nbsp;&amp;nbsp; n&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; =&amp;nbsp;&amp;nbsp; n(of v&lt;LI&gt;);&lt;/LI&gt;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp; &lt;STRONG style="color: navy; font-size: 10pt; background-color: white; font-family: 'Courier New';"&gt;run&lt;/STRONG&gt;&lt;SPAN style="font-size: 10pt; color: black; font-family: 'Courier New'; background-color: white;"&gt;;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;STRONG style="color: navy; font-size: 10pt; background-color: white; font-family: 'Courier New';"&gt;proc&lt;/STRONG&gt; &lt;STRONG style="color: navy; font-size: 10pt; background-color: white; font-family: 'Courier New';"&gt;print&lt;/STRONG&gt;&lt;SPAN style="font-size: 10pt; color: black; font-family: 'Courier New'; background-color: white;"&gt;;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp; &lt;STRONG style="color: navy; font-size: 10pt; background-color: white; font-family: 'Courier New';"&gt;run&lt;/STRONG&gt;;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;/PRE&gt;&lt;PRE __default_attr="plain" __jive_macro_name="code" class="jive_text_macro jive_macro_code"&gt;&lt;P&gt;&lt;SPAN style="font-size: 8pt; font-family: 'SAS Monospace';"&gt;Obs&amp;nbsp;&amp;nbsp;&amp;nbsp; Age&amp;nbsp;&amp;nbsp;&amp;nbsp; Height&amp;nbsp;&amp;nbsp;&amp;nbsp; Weight&amp;nbsp;&amp;nbsp;&amp;nbsp; Name&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; Sex&amp;nbsp;&amp;nbsp;&amp;nbsp; nmiss1&amp;nbsp;&amp;nbsp;&amp;nbsp; nmiss2&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; sum&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; n&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-size: 8pt; font-family: 'SAS Monospace';"&gt; &lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-size: 8pt; font-family: 'SAS Monospace';"&gt;&amp;nbsp; 1&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; 14&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; 69.0&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; 112.5&amp;nbsp;&amp;nbsp;&amp;nbsp; Alfred&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; M&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; 1&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; 0&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; 195.5&amp;nbsp;&amp;nbsp;&amp;nbsp; 3&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-size: 8pt; font-family: 'SAS Monospace';"&gt;&amp;nbsp; 2&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; 13&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; 56.5&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; 84.0&amp;nbsp;&amp;nbsp;&amp;nbsp; Alice&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; F&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; 1&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; 0&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; 153.5&amp;nbsp;&amp;nbsp;&amp;nbsp; 3&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-size: 8pt; font-family: 'SAS Monospace';"&gt;&amp;nbsp; 3&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; 13&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; 65.3&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; 98.0&amp;nbsp;&amp;nbsp;&amp;nbsp; Barbara&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; F&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; 1&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; 0&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; 176.3&amp;nbsp;&amp;nbsp;&amp;nbsp; 3&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-size: 8pt; font-family: 'SAS Monospace';"&gt;&amp;nbsp; 4&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; 14&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; 62.8&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; 102.5&amp;nbsp;&amp;nbsp;&amp;nbsp; Carol&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; F&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; 1&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; 0&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; 179.3&amp;nbsp;&amp;nbsp;&amp;nbsp; 3&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-size: 8pt; font-family: 'SAS Monospace';"&gt;&amp;nbsp; 5&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; 14&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; 63.5&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; 102.5&amp;nbsp;&amp;nbsp;&amp;nbsp; Henry&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; M&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; 1&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; 0&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; 180.0&amp;nbsp;&amp;nbsp;&amp;nbsp; 3&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-size: 8pt; font-family: 'SAS Monospace';"&gt;&amp;nbsp; 6&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; 12&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; 57.3&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; 83.0&amp;nbsp;&amp;nbsp;&amp;nbsp; James&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; M&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; 1&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; 0&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; 152.3&amp;nbsp;&amp;nbsp;&amp;nbsp; 3&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-size: 8pt; font-family: 'SAS Monospace';"&gt;&amp;nbsp; 7&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; 12&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; 59.8&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; 84.5&amp;nbsp;&amp;nbsp;&amp;nbsp; Jane&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; F&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; 1&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; 0&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; 156.3&amp;nbsp;&amp;nbsp;&amp;nbsp; 3&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-size: 8pt; font-family: 'SAS Monospace';"&gt;&amp;nbsp; 8&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; 15&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; 62.5&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; 112.5&amp;nbsp;&amp;nbsp;&amp;nbsp; Janet&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; F&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; 1&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; 0&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; 190.0&amp;nbsp;&amp;nbsp;&amp;nbsp; 3&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-size: 8pt; font-family: 'SAS Monospace';"&gt;&amp;nbsp; 9&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; 13&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; 62.5&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; 84.0&amp;nbsp;&amp;nbsp;&amp;nbsp; Jeffrey&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; M&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; 1&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; 0&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; 159.5&amp;nbsp;&amp;nbsp;&amp;nbsp; 3&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-size: 8pt; font-family: 'SAS Monospace';"&gt; 10&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; 12&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; 59.0&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; 99.5&amp;nbsp;&amp;nbsp;&amp;nbsp; John&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; M&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; 1&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; 0&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; 170.5&amp;nbsp;&amp;nbsp;&amp;nbsp; 3&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-size: 8pt; font-family: 'SAS Monospace';"&gt; 11&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; 11&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; 51.3&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; 50.5&amp;nbsp;&amp;nbsp;&amp;nbsp; Joyce&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; F&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; 1&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; 0&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; 112.8&amp;nbsp;&amp;nbsp;&amp;nbsp; 3&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-size: 8pt; font-family: 'SAS Monospace';"&gt; 12&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; 14&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; 64.3&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; 90.0&amp;nbsp;&amp;nbsp;&amp;nbsp; Judy&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; F&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; 1&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; 0&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; 168.3&amp;nbsp;&amp;nbsp;&amp;nbsp; 3&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-size: 8pt; font-family: 'SAS Monospace';"&gt; 13&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; 12&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; 56.3&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; 77.0&amp;nbsp;&amp;nbsp;&amp;nbsp; Louise&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; F&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; 1&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; 0&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; 145.3&amp;nbsp;&amp;nbsp;&amp;nbsp; 3&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-size: 8pt; font-family: 'SAS Monospace';"&gt; 14&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; 15&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; 66.5&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; 112.0&amp;nbsp;&amp;nbsp;&amp;nbsp; Mary&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; F&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; 1&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; 0&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; 193.5&amp;nbsp;&amp;nbsp;&amp;nbsp; 3&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-size: 8pt; font-family: 'SAS Monospace';"&gt; 15&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; 16&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; 72.0&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; 150.0&amp;nbsp;&amp;nbsp;&amp;nbsp; Philip&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; M&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; 1&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; 0&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; 238.0&amp;nbsp;&amp;nbsp;&amp;nbsp; 3&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-size: 8pt; font-family: 'SAS Monospace';"&gt; 16&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; 12&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; 64.8&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; 128.0&amp;nbsp;&amp;nbsp;&amp;nbsp; Robert&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; M&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; 1&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; 0&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; 204.8&amp;nbsp;&amp;nbsp;&amp;nbsp; 3&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-size: 8pt; font-family: 'SAS Monospace';"&gt; 17&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; 15&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; 67.0&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; 133.0&amp;nbsp;&amp;nbsp;&amp;nbsp; Ronald&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; M&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; 1&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; 0&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; 215.0&amp;nbsp;&amp;nbsp;&amp;nbsp; 3&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-size: 8pt; font-family: 'SAS Monospace';"&gt; 18&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; 11&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; 57.5&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; 85.0&amp;nbsp;&amp;nbsp;&amp;nbsp; Thomas&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; M&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; 1&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; 0&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; 153.5&amp;nbsp;&amp;nbsp;&amp;nbsp; 3&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-size: 8pt; font-family: 'SAS Monospace';"&gt; 19&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; 15&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; 66.5&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; 112.0&amp;nbsp;&amp;nbsp;&amp;nbsp; William&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; M&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; 1&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; 0&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; 193.5&amp;nbsp;&amp;nbsp;&amp;nbsp; 3&lt;/SPAN&gt;&lt;/P&gt;&lt;/PRE&gt;&lt;PRE __default_attr="plain" __jive_macro_name="code" class="jive_text_macro jive_macro_code"&gt;&lt;/PRE&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Mon, 10 Oct 2011 20:28:18 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Summing-all-numeric-variables-flexible-names-and-amount-of/m-p/27328#M4974</guid>
      <dc:creator>data_null__</dc:creator>
      <dc:date>2011-10-10T20:28:18Z</dc:date>
    </item>
    <item>
      <title>Summing all numeric variables (flexible names and amount of variables)</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Summing-all-numeric-variables-flexible-names-and-amount-of/m-p/27329#M4975</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;beware use of _numeric_ in a general context as a data set might bring in only _character_ variables. &lt;/P&gt;&lt;P&gt;One (fairly) safe solution &lt;/P&gt;&lt;P&gt;Array v(*) _n_ _numeric_ ; &lt;/P&gt;&lt;P&gt;Should you wish to ignore that _n_ in do loops, just&lt;/P&gt;&lt;P&gt;Do index = 2 to dim(v);&lt;/P&gt;&lt;P&gt;As _n_ will always be numeric&lt;/P&gt;&lt;P&gt;num_total = sum( of v(*))-_ n_;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;purists will point to the rare possibility that _n_ can become too large for integer precision and risk the num_total becoming incorrect. &lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Peter&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Tue, 11 Oct 2011 07:03:32 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Summing-all-numeric-variables-flexible-names-and-amount-of/m-p/27329#M4975</guid>
      <dc:creator>Peter_C</dc:creator>
      <dc:date>2011-10-11T07:03:32Z</dc:date>
    </item>
    <item>
      <title>Summing all numeric variables (flexible names and amount of variables)</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Summing-all-numeric-variables-flexible-names-and-amount-of/m-p/27330#M4976</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt; Good point that _NUMERIC_ might be NULL and SAS will not like that.&amp;nbsp; However adding a variable to unsure the array has at least one element would not be compatible with the statistic functions in general.&amp;nbsp; Guess we can't have out cake and eat it too.:smileygrin: Unless we resort to code gen.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Tue, 11 Oct 2011 11:40:24 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Summing-all-numeric-variables-flexible-names-and-amount-of/m-p/27330#M4976</guid>
      <dc:creator>data_null__</dc:creator>
      <dc:date>2011-10-11T11:40:24Z</dc:date>
    </item>
    <item>
      <title>Summing all numeric variables (flexible names and amount of variables)</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Summing-all-numeric-variables-flexible-names-and-amount-of/m-p/27331#M4977</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;not hard to test an array having only one element to avoid trying to produce those stats.&lt;/P&gt;&lt;P&gt;In that kind of way maybe we should avoid producing a deviation of one, etc&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Tue, 11 Oct 2011 12:58:48 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Summing-all-numeric-variables-flexible-names-and-amount-of/m-p/27331#M4977</guid>
      <dc:creator>Peter_C</dc:creator>
      <dc:date>2011-10-11T12:58:48Z</dc:date>
    </item>
    <item>
      <title>Summing all numeric variables (flexible names and amount of variables)</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Summing-all-numeric-variables-flexible-names-and-amount-of/m-p/27332#M4978</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;PRE __jive_macro_name="quote" class="jive_text_macro jive_macro_quote"&gt;&lt;P&gt;Peter.C wrote:&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;not hard to test an array having only one element to avoid trying to produce those stats.&lt;/P&gt;&lt;P&gt;In that kind of way maybe we should avoid producing a deviation of one, etc&lt;/P&gt;&lt;/PRE&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;That's not the problem I was thinking about.&amp;nbsp; Your example uses _N_ which is OK I suppose but it should be set to missing or better still use a DUMMY numeric that is always missing.&amp;nbsp; Then you don't have to "correct" any of the results except NMISS or CMISS.&amp;nbsp; At least I don't think any of the other statistic functions would need correcting.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Tue, 11 Oct 2011 14:04:27 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Summing-all-numeric-variables-flexible-names-and-amount-of/m-p/27332#M4978</guid>
      <dc:creator>data_null__</dc:creator>
      <dc:date>2011-10-11T14:04:27Z</dc:date>
    </item>
    <item>
      <title>Re: Summing all numeric variables (flexible names and amount of variables)</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Summing-all-numeric-variables-flexible-names-and-amount-of/m-p/27333#M4979</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;This is a great place to use a little SQL and macro to more precisely controlwhich variables you sum up later.&amp;nbsp; For my example, I'll use the CLASS data set in the SASHELP library.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;1.&amp;nbsp; First execute this SQL code (which can be used as a template) to get a list of all the numeric variables in the target dataset, collected a macro variable named VARLIST:&lt;/P&gt;&lt;PRE&gt;proc sql noprint;
select name into :Varnames separated by ' '
&amp;nbsp; from dictionary.columns
&amp;nbsp; where LIBNAME='SASHELP' 
&amp;nbsp;&amp;nbsp;&amp;nbsp; and MEMNAME='CLASS'
&amp;nbsp;&amp;nbsp;&amp;nbsp; and TYPE='num';
quit;&lt;/PRE&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;2. Next, use the macro variable to write the list for you in the subsequent DATA step code:&lt;/P&gt;&lt;PRE&gt;data want;
&amp;nbsp;&amp;nbsp; set sashelp.class;
&amp;nbsp;&amp;nbsp; total=sum(of &amp;amp;varnames);
run;
&lt;/PRE&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;DIV class="branch"&gt;&lt;P&gt;&lt;/P&gt;&lt;P style="page-break-after: always;"&gt;Partial results below:&lt;/P&gt;&lt;HR size="3" /&gt;&lt;DIV&gt;&lt;DIV align="center"&gt;&lt;TABLE cellpadding="5" cellspacing="0" class="table" frame="box" rules="all" summary="Procedure Print: Data Set WORK.WANT"&gt;&lt;THEAD&gt;&lt;TR&gt;&lt;TH class="r header" scope="col"&gt;Obs&lt;/TH&gt;&lt;TH class="l header" scope="col"&gt;Name&lt;/TH&gt;&lt;TH class="l header" scope="col"&gt;Sex&lt;/TH&gt;&lt;TH class="r header" scope="col"&gt;Age&lt;/TH&gt;&lt;TH class="r header" scope="col"&gt;Height&lt;/TH&gt;&lt;TH class="r header" scope="col"&gt;Weight&lt;/TH&gt;&lt;TH class="r header" scope="col"&gt;total&lt;/TH&gt;&lt;/TR&gt;&lt;/THEAD&gt;&lt;TBODY&gt;&lt;TR&gt;&lt;TH class="r rowheader" scope="row"&gt; 1&lt;/TH&gt;&lt;TD class="l data"&gt;Alfred&lt;/TD&gt;&lt;TD class="l data"&gt;M&lt;/TD&gt;&lt;TD class="r data"&gt;14&lt;/TD&gt;&lt;TD class="r data"&gt;69.0&lt;/TD&gt;&lt;TD class="r data"&gt;112.5&lt;/TD&gt;&lt;TD class="r data"&gt;195.5&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TH class="r rowheader" scope="row"&gt; 2&lt;/TH&gt;&lt;TD class="l data"&gt;Alice&lt;/TD&gt;&lt;TD class="l data"&gt;F&lt;/TD&gt;&lt;TD class="r data"&gt;13&lt;/TD&gt;&lt;TD class="r data"&gt;56.5&lt;/TD&gt;&lt;TD class="r data"&gt;84.0&lt;/TD&gt;&lt;TD class="r data"&gt;153.5&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TH class="r rowheader" scope="row"&gt; 3&lt;/TH&gt;&lt;TD class="l data"&gt;Barbara&lt;/TD&gt;&lt;TD class="l data"&gt;F&lt;/TD&gt;&lt;TD class="r data"&gt;13&lt;/TD&gt;&lt;TD class="r data"&gt;65.3&lt;/TD&gt;&lt;TD class="r data"&gt;98.0&lt;/TD&gt;&lt;TD class="r data"&gt;176.3&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TH class="r rowheader" scope="row"&gt; 4&lt;/TH&gt;&lt;TD class="l data"&gt;Carol&lt;/TD&gt;&lt;TD class="l data"&gt;F&lt;/TD&gt;&lt;TD class="r data"&gt;14&lt;/TD&gt;&lt;TD class="r data"&gt;62.8&lt;/TD&gt;&lt;TD class="r data"&gt;102.5&lt;/TD&gt;&lt;TD class="r data"&gt;179.3&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TH class="r rowheader" scope="row"&gt; 5&lt;/TH&gt;&lt;TD class="l data"&gt;Henry&lt;/TD&gt;&lt;TD class="l data"&gt;M&lt;/TD&gt;&lt;TD class="r data"&gt;14&lt;/TD&gt;&lt;TD class="r data"&gt;63.5&lt;/TD&gt;&lt;TD class="r data"&gt;102.5&lt;/TD&gt;&lt;TD class="r data"&gt;180.0&lt;/TD&gt;&lt;/TR&gt;&lt;/TBODY&gt;&lt;/TABLE&gt;&lt;/DIV&gt;&lt;/DIV&gt;&lt;/DIV&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Tue, 11 Oct 2011 14:06:43 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Summing-all-numeric-variables-flexible-names-and-amount-of/m-p/27333#M4979</guid>
      <dc:creator>SASJedi</dc:creator>
      <dc:date>2011-10-11T14:06:43Z</dc:date>
    </item>
    <item>
      <title>Summing all numeric variables (flexible names and amount of variables)</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Summing-all-numeric-variables-flexible-names-and-amount-of/m-p/27334#M4980</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt; have you any protection against the source data set having no numeric variables?&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Tue, 11 Oct 2011 15:13:00 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Summing-all-numeric-variables-flexible-names-and-amount-of/m-p/27334#M4980</guid>
      <dc:creator>Peter_C</dc:creator>
      <dc:date>2011-10-11T15:13:00Z</dc:date>
    </item>
    <item>
      <title>Re: Summing all numeric variables (flexible names and amount of variables)</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Summing-all-numeric-variables-flexible-names-and-amount-of/m-p/27335#M4981</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;total = sum(of total &amp;amp;varnames);&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Remember add a %LET varnames=; statement BEFORE the SQL query so that any existing list of values is not retained in the macro variable.&amp;nbsp; PROC SQL will not modify the value of the target macro variable when no rows are selected.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Of course this gets us back to the original reply.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;total=sum(of _numeric_);&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Tue, 11 Oct 2011 15:27:27 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Summing-all-numeric-variables-flexible-names-and-amount-of/m-p/27335#M4981</guid>
      <dc:creator>Tom</dc:creator>
      <dc:date>2011-10-11T15:27:27Z</dc:date>
    </item>
    <item>
      <title>Summing all numeric variables (flexible names and amount of variables)</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Summing-all-numeric-variables-flexible-names-and-amount-of/m-p/27336#M4982</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;%macro vnumlist(lib, sds, svar);&lt;/P&gt;&lt;P&gt; %global g_vnumsum;&lt;/P&gt;&lt;P&gt; proc sql noprint;&lt;/P&gt;&lt;P&gt;&amp;nbsp; select count(*) into :vnobs&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; from sashelp.vcolumn&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp; where libname="%upcase(&amp;amp;lib)"&lt;/P&gt;&lt;P&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; and memname="%upcase(&amp;amp;sds)"&lt;/P&gt;&lt;P&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;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; and type='num';&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt; %if &amp;amp;vnobs&amp;gt;0 %then&lt;/P&gt;&lt;P&gt;&amp;nbsp; %do;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp; select name into :vnames separated by ' '&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; from sashelp.vcolumn&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; where libname="%upcase(&amp;amp;lib)"&lt;/P&gt;&lt;P&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; and memname="%upcase(&amp;amp;sds)"&lt;/P&gt;&lt;P&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;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; and type='num';&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp; %let g_vnumsum=&amp;amp;svar=sum(of &amp;amp;vnames);&lt;/P&gt;&lt;P&gt;&amp;nbsp; %end;&lt;/P&gt;&lt;P&gt; %else &lt;/P&gt;&lt;P&gt;&amp;nbsp; %do;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp; %let g_vnumsum=%str();&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp; %put WARNING: No Numeric Variables to Sum;&lt;/P&gt;&lt;P&gt;&amp;nbsp; %end;&lt;/P&gt;&lt;P&gt; quit;&lt;/P&gt;&lt;P&gt;%mend;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;%vnumlist(sashelp, class, total)&lt;/P&gt;&lt;P&gt;data want;&lt;/P&gt;&lt;P&gt; set sashelp.class;&lt;/P&gt;&lt;P&gt; &amp;amp;g_vnumsum;&lt;/P&gt;&lt;P&gt;run;&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Tue, 11 Oct 2011 16:28:50 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Summing-all-numeric-variables-flexible-names-and-amount-of/m-p/27336#M4982</guid>
      <dc:creator>FriedEgg</dc:creator>
      <dc:date>2011-10-11T16:28:50Z</dc:date>
    </item>
    <item>
      <title>Re: Summing all numeric variables (flexible names and amount of variables)</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Summing-all-numeric-variables-flexible-names-and-amount-of/m-p/27337#M4983</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;If you want to create a macro you can make it more efficient.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;First you do not need to query twice to find the number of variables. SAS will set the automatic variable SQLOBS with the count.&lt;/P&gt;&lt;P&gt;Second can depend it not changing the value of the existing variable when there are no rows selected.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;PRE __jive_macro_name="quote" class="jive_text_macro jive_macro_quote"&gt;&lt;P&gt;&lt;SPAN style="font-family: 'courier new', courier;"&gt;%macro vnumlist(lib, sds, svar);&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-family: 'courier new', courier;"&gt;%global g_vnumsum;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-family: 'courier new', courier;"&gt;%let g_vnumsum=;&lt;BR /&gt;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-family: 'courier new', courier;"&gt;proc sql noprint;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-family: 'courier new', courier;"&gt;&amp;nbsp;&amp;nbsp; select name into :g_vnumsum separated by ' '&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-family: 'courier new', courier;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; from dictionary.columns&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-family: 'courier new', courier;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; where libname="%upcase(&amp;amp;lib)"&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-family: 'courier new', courier;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; and memname="%upcase(&amp;amp;sds)"&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-family: 'courier new', courier;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; and type='num'&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-family: 'courier new', courier;"&gt;&amp;nbsp;&amp;nbsp; ;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-family: 'courier new', courier;"&gt;quit;&lt;BR /&gt;&lt;/SPAN&gt;&lt;/P&gt;&lt;P style="min-height: 8pt; height: 8pt;"&gt;&lt;SPAN style="font-family: 'courier new', courier;"&gt;%if &amp;amp;sqlobs %then %let g_vnumsum=&amp;amp;svar = sum(of &amp;amp;g_vnumsum); &lt;/SPAN&gt;&lt;/P&gt;&lt;P style="min-height: 8pt; height: 8pt;"&gt;&lt;SPAN style="font-family: 'courier new', courier;"&gt;%else %put WARNING: No Numeric Variables to Sum;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-family: 'courier new', courier;"&gt;%mend vnumlist;&lt;/SPAN&gt;&lt;/P&gt;&lt;/PRE&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Tue, 11 Oct 2011 16:48:29 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Summing-all-numeric-variables-flexible-names-and-amount-of/m-p/27337#M4983</guid>
      <dc:creator>Tom</dc:creator>
      <dc:date>2011-10-11T16:48:29Z</dc:date>
    </item>
    <item>
      <title>Summing all numeric variables (flexible names and amount of variables)</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Summing-all-numeric-variables-flexible-names-and-amount-of/m-p/27338#M4984</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Nicely done Tom, thanks.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Tue, 11 Oct 2011 17:10:26 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Summing-all-numeric-variables-flexible-names-and-amount-of/m-p/27338#M4984</guid>
      <dc:creator>FriedEgg</dc:creator>
      <dc:date>2011-10-11T17:10:26Z</dc:date>
    </item>
    <item>
      <title>Re: Summing all numeric variables (flexible names and amount of variables)</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Summing-all-numeric-variables-flexible-names-and-amount-of/m-p/27339#M4985</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;A more sophisticated macro application with extensive parameter checking would provide protection against this and more...&amp;nbsp; I thought I'd keep it simple as the original poster stated he was just learning SAS, and I didn't want to over complicate the issue.&amp;nbsp; However, something like this would be a good start towards a more robust app:&lt;/P&gt;&lt;PRE&gt; 
%macro SumNums(DSN_In,DSN_Out, Sumvar);
%local Varnames LIB DSN;
&amp;nbsp; /* Did the user provide an input dataset name? */
%if &amp;amp;DSN_In= %then %do;
&amp;nbsp;&amp;nbsp; %put ERROR: (SumNums) You must provide the name of the data set you wish to process.;
&amp;nbsp;&amp;nbsp; %SyntaxHelp:
&amp;nbsp;&amp;nbsp; %put NOTE- SYNTAX:&amp;nbsp; %NRSTR(%%SumNums%(DSN_In,DSN_Out,Sumvar%));
&amp;nbsp;&amp;nbsp; %put NOTE-&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; DSN_In =Name of data set to process;
&amp;nbsp;&amp;nbsp; %put NOTE-&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; DSN_Out=Name of output data set;
&amp;nbsp;&amp;nbsp; %put NOTE-&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; Sumvar =Variable name to hold the sum (default is Total);
&amp;nbsp;&amp;nbsp; %put NOTE- Example: %NRSTR(%%SumNums%(sashelp.class,work.test%));
&amp;nbsp;&amp;nbsp; %GoTo EndMacro;
%end;
%let DSN_In=%QUPCASE(&amp;amp;DSN_In);

&amp;nbsp; /* Did the user ask for syntax help? */
%if &amp;amp;DSN_In=!HELP %then %do;
&amp;nbsp;&amp;nbsp; %GoTo SyntaxHelp;
%end;
&amp;nbsp; /* Did the user provide an output dataset name? */
%if &amp;amp;DSN_Out= %then %do;
&amp;nbsp;&amp;nbsp; %put ERROR: (SumNums) You must provide the name of the output data set.;
&amp;nbsp;&amp;nbsp; %GoTo SyntaxHelp;
%end;
%let DSN_Out=%QUPCASE(&amp;amp;DSN_Out);
&amp;nbsp; /* Is the sum variable given a valid SAS variable name? */
%if &amp;amp;sumvar= %then %let Sumvar=Total;
%if not %sysfunc(nvalid(%superq(Sumvar))) %then %do;
&amp;nbsp;&amp;nbsp; %put ERROR: (SumNums) %superq(Sumvar) is not a valid SAS variable name.;
&amp;nbsp;&amp;nbsp; %GoTo SyntaxHelp;
%end;

%let DSN=%QSCAN(&amp;amp;DSN_In,2,.);
%if &amp;amp;DSN= %then %do;
&amp;nbsp;&amp;nbsp; %let DSN=%SUPERQ(DSN_In);
&amp;nbsp;&amp;nbsp; %let LIB=WORK;
%end;
%else %let LIB=%QSCAN(&amp;amp;DSN_In,1,.);

proc sql noprint;
select name into :Varnames separated by ' '
&amp;nbsp; from dictionary.columns
&amp;nbsp; where LIBNAME="&amp;amp;LIB" 
&amp;nbsp;&amp;nbsp;&amp;nbsp; and MEMNAME="&amp;amp;DSN"
&amp;nbsp;&amp;nbsp;&amp;nbsp; and TYPE='num'
;
quit;

&amp;nbsp; /* Were there any numeric variables in the input data set? */
%if &amp;amp;SQLOBS=0 %then %do;
&amp;nbsp;&amp;nbsp; %put WARNING: (SumNums) dataset &amp;amp;DSN_In contained no numeric variables.;
&amp;nbsp;&amp;nbsp; %GoTo EndMacro;
%end;
&amp;nbsp; /* Do the deed! */
data &amp;amp;DSN_out;
&amp;nbsp;&amp;nbsp; set &amp;amp;DSN_In;
&amp;nbsp;&amp;nbsp; &amp;amp;Sumvar=sum(of &amp;amp;varnames);
run;

%EndMacro:
%Mend SumNums;
&lt;/PRE&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;After compiling, you just call the macro to do the deed.&lt;/P&gt;&lt;P&gt;Example of a call for SYNTAX help:&lt;/P&gt;&lt;PRE&gt;%SumNums(!HELP)&lt;/PRE&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Example of a call to calculate the total for SASHELP.CLASS:&lt;/P&gt;&lt;PRE&gt;%SumNums(sashelp.class,work.test,MySumVar)&lt;/PRE&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Tue, 11 Oct 2011 20:51:20 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Summing-all-numeric-variables-flexible-names-and-amount-of/m-p/27339#M4985</guid>
      <dc:creator>SASJedi</dc:creator>
      <dc:date>2011-10-11T20:51:20Z</dc:date>
    </item>
    <item>
      <title>Re: Summing all numeric variables (flexible names and amount of variables)</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Summing-all-numeric-variables-flexible-names-and-amount-of/m-p/27340#M4986</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;I like the improved usability of using a single parameter to specify the dataset name versus separate libname and membername fields.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;UL&gt;&lt;LI&gt;You are testing the value of the parameters before you have protected them with quoting functions.&lt;/LI&gt;&lt;LI&gt;You should check all of the parameters you can before bailing out.&lt;/LI&gt;&lt;LI&gt;You might want to test for existence of the input dataset.&lt;/LI&gt;&lt;LI&gt;You might want to exclude &amp;amp;SUMVAR from the list of variables to include in the sum.&lt;/LI&gt;&lt;LI&gt;For even more usability you can establish defaults for some parameters.&amp;nbsp; To me the only required parameter here is the target variable name.&amp;nbsp; The default to the input dataset could be &amp;amp;syslast.&amp;nbsp; The default for the output dataset could be null string so that SAS will create DATAnn where nn is the next number after the last DATAnn that it created.&lt;/LI&gt;&lt;/UL&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Tue, 11 Oct 2011 22:27:25 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Summing-all-numeric-variables-flexible-names-and-amount-of/m-p/27340#M4986</guid>
      <dc:creator>Tom</dc:creator>
      <dc:date>2011-10-11T22:27:25Z</dc:date>
    </item>
    <item>
      <title>Re: Summing all numeric variables (flexible names and amount of variables)</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Summing-all-numeric-variables-flexible-names-and-amount-of/m-p/27341#M4987</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Wow, gentlemen, I am really surprised with how detailed and useful your answers are &lt;img id="smileyhappy" class="emoticon emoticon-smileyhappy" src="https://communities.sas.com/i/smilies/16x16_smiley-happy.png" alt="Smiley Happy" title="Smiley Happy" /&gt;&amp;nbsp; When I see these tricks I have two contradictory feelings: 1) I feel upset about my poor knowledge of SAS and 2) I feel glad that there are so many interesting things to learn&lt;img id="smileyhappy" class="emoticon emoticon-smileyhappy" src="https://communities.sas.com/i/smilies/16x16_smiley-happy.png" alt="Smiley Happy" title="Smiley Happy" /&gt;&lt;/P&gt;&lt;P&gt;Thanks a lot to all of you.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Wed, 12 Oct 2011 16:51:36 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Summing-all-numeric-variables-flexible-names-and-amount-of/m-p/27341#M4987</guid>
      <dc:creator>Quadraaa</dc:creator>
      <dc:date>2011-10-12T16:51:36Z</dc:date>
    </item>
    <item>
      <title>Summing all numeric variables (flexible names and amount of variables)</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Summing-all-numeric-variables-flexible-names-and-amount-of/m-p/27342#M4988</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;I have to send a kudos to SASJedi as well for going well beyond in his response what I would consider necessary and giving you not just an answer to point you in a direction but a real process to utilize.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Wed, 12 Oct 2011 18:28:25 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Summing-all-numeric-variables-flexible-names-and-amount-of/m-p/27342#M4988</guid>
      <dc:creator>FriedEgg</dc:creator>
      <dc:date>2011-10-12T18:28:25Z</dc:date>
    </item>
    <item>
      <title>Re: Summing all numeric variables (flexible names and amount of variables)</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Summing-all-numeric-variables-flexible-names-and-amount-of/m-p/27343#M4989</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;I have to share my code: &lt;/P&gt;&lt;P&gt;I know it's a closed topic but I think this could be useful.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;/************************************************************************************/&lt;/P&gt;&lt;P&gt;/* Descripcion general del programa:&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;&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;&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;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; */&lt;/P&gt;&lt;P&gt;/* Suma las variables numericas de una tabla, sin especificar nombres. */&lt;/P&gt;&lt;P&gt;/* Autor&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; : Saul Sanchez Sánchez&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;&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;&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; */&lt;/P&gt;&lt;P&gt;/************************************************************************************/&lt;/P&gt;&lt;P&gt;data a;&lt;/P&gt;&lt;P&gt; do i=1 to 100;&lt;/P&gt;&lt;P&gt;&amp;nbsp; a=abs(int(rand('NORMAL')*1000));&lt;/P&gt;&lt;P&gt;&amp;nbsp; b=abs(int(rand('NORMAL')*1000));&lt;/P&gt;&lt;P&gt;&amp;nbsp; c=abs(int(rand('NORMAL')*1000));&lt;/P&gt;&lt;P&gt;&amp;nbsp; cl='a'||substr(left(compress(i)),1,1);&lt;/P&gt;&lt;P&gt;&amp;nbsp; output;&lt;/P&gt;&lt;P&gt; end;&lt;/P&gt;&lt;P&gt;run;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;data vars(where=(type='N'));&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp; length name $ 8 type $ 1;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp; drop dsid i num rc;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp; dsid=open("work.a","i");&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp; num=attrn(dsid,"nvars");&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp; do i=1 to num;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; name=varname(dsid,i);&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; type=vartype(dsid,i);&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; output;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp; end;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp; rc=close(dsid);&lt;/P&gt;&lt;P&gt;run;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;data vars(keep=function);&lt;/P&gt;&lt;P&gt; set vars;&lt;/P&gt;&lt;P&gt; function='sum('||compress(name)||') as '||compress(name);&lt;/P&gt;&lt;P&gt;run;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;proc sql;&lt;/P&gt;&lt;P&gt; select function into :function separated by ','&lt;/P&gt;&lt;P&gt; from vars;&lt;/P&gt;&lt;P&gt;quit;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;%put &amp;amp;function;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;proc sql;&lt;/P&gt;&lt;P&gt; create table b as &lt;/P&gt;&lt;P&gt; select cl, &amp;amp;function&lt;/P&gt;&lt;P&gt; from a&lt;/P&gt;&lt;P&gt; group by 1;&lt;/P&gt;&lt;P&gt;run;&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Wed, 20 May 2015 16:21:16 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Summing-all-numeric-variables-flexible-names-and-amount-of/m-p/27343#M4989</guid>
      <dc:creator>slsnx2</dc:creator>
      <dc:date>2015-05-20T16:21:16Z</dc:date>
    </item>
  </channel>
</rss>

