<?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 function in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/sum-function/m-p/143900#M28733</link>
    <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;hi Arthur,&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;thanks for the quick response. Here is the code that i used for creating the two macro variables look like this:&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;proc sql;&lt;/P&gt;&lt;P&gt;select Feld&lt;/P&gt;&lt;P&gt;into :gIS separated by ' '&lt;/P&gt;&lt;P&gt;from informappe&lt;/P&gt;&lt;P&gt;where ...; /*here i omitted the conditions */&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;select Feld&lt;/P&gt;&lt;P&gt;into :gSHOULD separated by ' '&lt;/P&gt;&lt;P&gt;from informappe&lt;/P&gt;&lt;P&gt;where...;&lt;/P&gt;&lt;P&gt;quit;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;the two macro variables have the same number of variables saved, like 40.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;and then i have a big dataset have, which contains all the variables, including all variables from gIS and gSHOULD. I would like to create a new dataset want, with all the variables in gIS and gSHOULD from have, and then add two new variables sumIS and sumSHOULD to it, which contains just the sum of the variables in gIS and the sum of variables in gSHOULD.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;for example var1-var40 are included in gIS and var41-var80 are included in gSHOULD. If I just select these variables from have, one observation looks like:&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;var1 var2 var3 var4....var40 var41 var42...var80&lt;/P&gt;&lt;P&gt;1&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; 1&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; 1&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; 1&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; 2&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; 2&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; 2&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;then the sumIS and sumSHOULD for the same observation is 40 and 80. and want looks like:&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;var1 var2 var3 var4....var40 var41 var42...var80 sumIS sumSHOULD&lt;/P&gt;&lt;P&gt;1&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; 1&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; 1&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; 1&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; 2&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; 2&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; 2&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; 40&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; 80&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;I hope i made myself clear this time.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;BR&amp;nbsp; Dingdang &lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
    <pubDate>Thu, 14 Nov 2013 17:27:20 GMT</pubDate>
    <dc:creator>Dingdang</dc:creator>
    <dc:date>2013-11-14T17:27:20Z</dc:date>
    <item>
      <title>sum function</title>
      <link>https://communities.sas.com/t5/SAS-Programming/sum-function/m-p/143896#M28729</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hi,&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;I have a dataset and i've saved the variables of it into two macro variables &amp;amp;gIS and &amp;amp;gSHOULD, i want to add two new columns to this dataset, summing over all the variables in &amp;amp;gIS and &amp;amp;gSHOULD. I wrote the following code but nothing happened &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; the want i got is the same as have&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;DATA libl.want;&lt;/P&gt;&lt;P&gt;SET libl.have;&lt;/P&gt;&lt;P&gt;keep &amp;amp;gIS &amp;amp;gSHOULD;&lt;/P&gt;&lt;P&gt;sumIS=sum(of &amp;amp;gIS);&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; /*In the hope that sumIS is the sum of all the variables in &amp;amp;gIS for all the observations. */&lt;/P&gt;&lt;P&gt;sumSHOULD=sum(of &amp;amp;gSHOULD);&lt;/P&gt;&lt;P&gt;RUN;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Can someone help me correct my code? Thanks very much.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;BR&amp;nbsp; Dingdang&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Thu, 14 Nov 2013 16:52:03 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/sum-function/m-p/143896#M28729</guid>
      <dc:creator>Dingdang</dc:creator>
      <dc:date>2013-11-14T16:52:03Z</dc:date>
    </item>
    <item>
      <title>Re: sum function</title>
      <link>https://communities.sas.com/t5/SAS-Programming/sum-function/m-p/143897#M28730</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Can you provide example have and want datasets, as well as the code you are using to create the macro variables?&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Thu, 14 Nov 2013 17:01:14 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/sum-function/m-p/143897#M28730</guid>
      <dc:creator>art297</dc:creator>
      <dc:date>2013-11-14T17:01:14Z</dc:date>
    </item>
    <item>
      <title>Re: sum function</title>
      <link>https://communities.sas.com/t5/SAS-Programming/sum-function/m-p/143898#M28731</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;What does &amp;amp;GLS look like? Using sum( of &amp;amp;gls) the sum function expects to see a variable list such as X1-x5 or X: If &amp;amp;GLS is a list of variables with spaces then the syntax is incorrect. If &amp;amp;gls is a list of variable or values then they should be comma delimited.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Thu, 14 Nov 2013 17:12:36 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/sum-function/m-p/143898#M28731</guid>
      <dc:creator>ballardw</dc:creator>
      <dc:date>2013-11-14T17:12:36Z</dc:date>
    </item>
    <item>
      <title>Re: sum function</title>
      <link>https://communities.sas.com/t5/SAS-Programming/sum-function/m-p/143899#M28732</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hi,&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Do you get any warning or error messages? Perhaps post your log too.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Regards,&lt;/P&gt;&lt;P&gt;Amir.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Thu, 14 Nov 2013 17:17:26 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/sum-function/m-p/143899#M28732</guid>
      <dc:creator>Amir</dc:creator>
      <dc:date>2013-11-14T17:17:26Z</dc:date>
    </item>
    <item>
      <title>Re: sum function</title>
      <link>https://communities.sas.com/t5/SAS-Programming/sum-function/m-p/143900#M28733</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;hi Arthur,&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;thanks for the quick response. Here is the code that i used for creating the two macro variables look like this:&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;proc sql;&lt;/P&gt;&lt;P&gt;select Feld&lt;/P&gt;&lt;P&gt;into :gIS separated by ' '&lt;/P&gt;&lt;P&gt;from informappe&lt;/P&gt;&lt;P&gt;where ...; /*here i omitted the conditions */&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;select Feld&lt;/P&gt;&lt;P&gt;into :gSHOULD separated by ' '&lt;/P&gt;&lt;P&gt;from informappe&lt;/P&gt;&lt;P&gt;where...;&lt;/P&gt;&lt;P&gt;quit;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;the two macro variables have the same number of variables saved, like 40.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;and then i have a big dataset have, which contains all the variables, including all variables from gIS and gSHOULD. I would like to create a new dataset want, with all the variables in gIS and gSHOULD from have, and then add two new variables sumIS and sumSHOULD to it, which contains just the sum of the variables in gIS and the sum of variables in gSHOULD.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;for example var1-var40 are included in gIS and var41-var80 are included in gSHOULD. If I just select these variables from have, one observation looks like:&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;var1 var2 var3 var4....var40 var41 var42...var80&lt;/P&gt;&lt;P&gt;1&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; 1&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; 1&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; 1&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; 2&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; 2&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; 2&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;then the sumIS and sumSHOULD for the same observation is 40 and 80. and want looks like:&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;var1 var2 var3 var4....var40 var41 var42...var80 sumIS sumSHOULD&lt;/P&gt;&lt;P&gt;1&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; 1&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; 1&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; 1&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; 2&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; 2&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; 2&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; 40&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; 80&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;I hope i made myself clear this time.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;BR&amp;nbsp; Dingdang &lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Thu, 14 Nov 2013 17:27:20 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/sum-function/m-p/143900#M28733</guid>
      <dc:creator>Dingdang</dc:creator>
      <dc:date>2013-11-14T17:27:20Z</dc:date>
    </item>
    <item>
      <title>Re: sum function</title>
      <link>https://communities.sas.com/t5/SAS-Programming/sum-function/m-p/143901#M28734</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;You are not keeping the new summed variables.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-family: 'courier new', courier; background-color: #ffffff; font-size: 12pt;"&gt;keep &amp;amp;gIS &amp;amp;gSHOULD &lt;SPAN style="background-color: #ffffff;"&gt;sumIS&lt;/SPAN&gt; sumSHOULD;&lt;/SPAN&gt;&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Thu, 14 Nov 2013 17:43:14 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/sum-function/m-p/143901#M28734</guid>
      <dc:creator>Tom</dc:creator>
      <dc:date>2013-11-14T17:43:14Z</dc:date>
    </item>
    <item>
      <title>Re: sum function</title>
      <link>https://communities.sas.com/t5/SAS-Programming/sum-function/m-p/143902#M28735</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;I read the use of sum function again and corrected the macro variables to comma delimited and then used sum(&amp;amp;gIS) and then it worked!! best thanks!!&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Fri, 15 Nov 2013 08:20:43 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/sum-function/m-p/143902#M28735</guid>
      <dc:creator>Dingdang</dc:creator>
      <dc:date>2013-11-15T08:20:43Z</dc:date>
    </item>
  </channel>
</rss>

