<?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: Calculating the Total Amount with random number of variables in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/Calculating-the-Total-Amount-with-random-number-of-variables/m-p/607292#M176496</link>
    <description>&lt;P&gt;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/10892"&gt;@PaigeMiller&lt;/a&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;What if you don't know how many variables are in the data?&lt;/P&gt;&lt;P&gt;I mean in the datalines, there are random number of amount variables. (You don't know the maximum number of Amount Variable)&lt;/P&gt;&lt;P&gt;Datalines above is just an example in a whole datalines&lt;/P&gt;</description>
    <pubDate>Tue, 26 Nov 2019 12:04:58 GMT</pubDate>
    <dc:creator>skjhzzang</dc:creator>
    <dc:date>2019-11-26T12:04:58Z</dc:date>
    <item>
      <title>Calculating the Total Amount with random number of variables</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Calculating-the-Total-Amount-with-random-number-of-variables/m-p/607277#M176483</link>
      <description>&lt;P&gt;For example below&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Peter &amp;nbsp;2 &amp;nbsp;14 &amp;nbsp;16&lt;/P&gt;&lt;P&gt;James &amp;nbsp;3 &amp;nbsp;17 &amp;nbsp;19 &amp;nbsp;18&lt;/P&gt;&lt;P&gt;Max &amp;nbsp;1 &amp;nbsp;7&lt;/P&gt;&lt;P&gt;Logan &amp;nbsp;5 &amp;nbsp;19 &amp;nbsp;15 &amp;nbsp;11 &amp;nbsp;9 &amp;nbsp;18&lt;/P&gt;&lt;P&gt;…&lt;/P&gt;&lt;P&gt;…&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;First variable is Name, Second variable is number of visit and others are amounts.&lt;/P&gt;&lt;P&gt;Peter visited twice so there are 2 amount variables and James visited three times so there are 3 amount variables.&lt;/P&gt;&lt;P&gt;Is it possible to just ignore reading Amount variables and just calculate sum of amount variables for each person and running total of the total amount variables for each person in a single data step?&amp;nbsp;&lt;/P&gt;&lt;P&gt;Result should be like this.&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;Name&amp;nbsp; &amp;nbsp;TotalAmt&amp;nbsp; Runtotal&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;Peter&amp;nbsp; &amp;nbsp; 30&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; 30&lt;/P&gt;&lt;P&gt;James&amp;nbsp; 54&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; 84&lt;/P&gt;&lt;P&gt;Max&amp;nbsp; &amp;nbsp; &amp;nbsp; 7&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; 91&lt;/P&gt;&lt;P&gt;Logan&amp;nbsp; 72&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;163&lt;/P&gt;&lt;P&gt;...&lt;/P&gt;&lt;P&gt;...&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Tue, 26 Nov 2019 11:29:00 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Calculating-the-Total-Amount-with-random-number-of-variables/m-p/607277#M176483</guid>
      <dc:creator>skjhzzang</dc:creator>
      <dc:date>2019-11-26T11:29:00Z</dc:date>
    </item>
    <item>
      <title>Re: Calculating the Total Amount with random number of variables</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Calculating-the-Total-Amount-with-random-number-of-variables/m-p/607280#M176486</link>
      <description>&lt;P&gt;assuming you have variables named AMOUNT1-AMOUNT5&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Use&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;totalamt=sum(of amount1-amount5);
runtotal+totalamt;&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Tue, 26 Nov 2019 11:38:25 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Calculating-the-Total-Amount-with-random-number-of-variables/m-p/607280#M176486</guid>
      <dc:creator>PaigeMiller</dc:creator>
      <dc:date>2019-11-26T11:38:25Z</dc:date>
    </item>
    <item>
      <title>Re: Calculating the Total Amount with random number of variables</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Calculating-the-Total-Amount-with-random-number-of-variables/m-p/607292#M176496</link>
      <description>&lt;P&gt;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/10892"&gt;@PaigeMiller&lt;/a&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;What if you don't know how many variables are in the data?&lt;/P&gt;&lt;P&gt;I mean in the datalines, there are random number of amount variables. (You don't know the maximum number of Amount Variable)&lt;/P&gt;&lt;P&gt;Datalines above is just an example in a whole datalines&lt;/P&gt;</description>
      <pubDate>Tue, 26 Nov 2019 12:04:58 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Calculating-the-Total-Amount-with-random-number-of-variables/m-p/607292#M176496</guid>
      <dc:creator>skjhzzang</dc:creator>
      <dc:date>2019-11-26T12:04:58Z</dc:date>
    </item>
    <item>
      <title>Re: Calculating the Total Amount with random number of variables</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Calculating-the-Total-Amount-with-random-number-of-variables/m-p/607318#M176504</link>
      <description>&lt;P&gt;Surely you must have a SAS data set. PROC CONTENTS will tell you what variables exist, you can use that information.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Please show us an actual SAS data set, following these instructions:&amp;nbsp;&lt;A href="https://communities.sas.com/t5/SAS-Communities-Library/How-to-create-a-data-step-version-of-your-data-AKA-generate/ta-p/258712" target="_blank"&gt;https://communities.sas.com/t5/SAS-Communities-Library/How-to-create-a-data-step-version-of-your-data-AKA-generate/ta-p/258712&lt;/A&gt;&lt;/P&gt;</description>
      <pubDate>Tue, 26 Nov 2019 12:57:33 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Calculating-the-Total-Amount-with-random-number-of-variables/m-p/607318#M176504</guid>
      <dc:creator>PaigeMiller</dc:creator>
      <dc:date>2019-11-26T12:57:33Z</dc:date>
    </item>
  </channel>
</rss>

