<?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: cummulative variable in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/cummulative-variable/m-p/588758#M168313</link>
    <description>&lt;P&gt;I am getting same reading as neurosurgery its not giving me cummulative&lt;/P&gt;&lt;P&gt;do I have to place retain some where&lt;/P&gt;</description>
    <pubDate>Sat, 14 Sep 2019 19:36:09 GMT</pubDate>
    <dc:creator>ambreen</dc:creator>
    <dc:date>2019-09-14T19:36:09Z</dc:date>
    <item>
      <title>cummulative variable</title>
      <link>https://communities.sas.com/t5/SAS-Programming/cummulative-variable/m-p/588756#M168311</link>
      <description>&lt;P&gt;&lt;FONT&gt;libname hw5a "C:\Users\noor\Desktop";&lt;BR /&gt;data hw5a;&lt;BR /&gt;set hw5a.HW5a;&lt;BR /&gt;by week;&lt;BR /&gt;if first.Week then cumNsurgery= Nsurgery;&lt;BR /&gt;else cumNsurgery + Nsurgery;&lt;BR /&gt;keep;&lt;BR /&gt;run;&lt;/FONT&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;FONT&gt;&amp;nbsp;I am trying to create a cumulative but whats wrong with my code&lt;/FONT&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;FONT&gt;my data is&amp;nbsp;&lt;/FONT&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;FONT&gt;week&amp;nbsp; Nsurgery&lt;/FONT&gt;&lt;/P&gt;&lt;P&gt;&lt;FONT&gt;1 &amp;nbsp; &amp;nbsp;&amp;nbsp; 1&lt;/FONT&gt;&lt;/P&gt;&lt;P&gt;&lt;FONT&gt;2 &amp;nbsp;&amp;nbsp; 0&lt;/FONT&gt;&lt;/P&gt;&lt;P&gt;&lt;FONT&gt;3 &amp;nbsp; &amp;nbsp; 5&lt;/FONT&gt;&lt;/P&gt;&lt;P&gt;&lt;FONT&gt;4 &amp;nbsp; &amp;nbsp; 7&lt;/FONT&gt;&lt;/P&gt;&lt;P&gt;&lt;FONT&gt;5 &amp;nbsp;&amp;nbsp; 4&lt;/FONT&gt;&lt;/P&gt;&lt;P&gt;&lt;FONT&gt;6 &amp;nbsp;&amp;nbsp; 0&lt;/FONT&gt;&lt;/P&gt;&lt;P&gt;&lt;FONT&gt;7 &amp;nbsp;&amp;nbsp; 1&lt;/FONT&gt;&lt;/P&gt;&lt;P&gt;&lt;FONT&gt;8 &amp;nbsp;&amp;nbsp; 3&lt;/FONT&gt;&lt;/P&gt;&lt;P&gt;&lt;FONT&gt;9 &amp;nbsp;&amp;nbsp; 5&lt;/FONT&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Sat, 14 Sep 2019 22:21:13 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/cummulative-variable/m-p/588756#M168311</guid>
      <dc:creator>ambreen</dc:creator>
      <dc:date>2019-09-14T22:21:13Z</dc:date>
    </item>
    <item>
      <title>Re: cummulative variable</title>
      <link>https://communities.sas.com/t5/SAS-Programming/cummulative-variable/m-p/588757#M168312</link>
      <description>&lt;P&gt;What's the problem?&lt;/P&gt;</description>
      <pubDate>Sat, 14 Sep 2019 19:28:03 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/cummulative-variable/m-p/588757#M168312</guid>
      <dc:creator>PGStats</dc:creator>
      <dc:date>2019-09-14T19:28:03Z</dc:date>
    </item>
    <item>
      <title>Re: cummulative variable</title>
      <link>https://communities.sas.com/t5/SAS-Programming/cummulative-variable/m-p/588758#M168313</link>
      <description>&lt;P&gt;I am getting same reading as neurosurgery its not giving me cummulative&lt;/P&gt;&lt;P&gt;do I have to place retain some where&lt;/P&gt;</description>
      <pubDate>Sat, 14 Sep 2019 19:36:09 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/cummulative-variable/m-p/588758#M168313</guid>
      <dc:creator>ambreen</dc:creator>
      <dc:date>2019-09-14T19:36:09Z</dc:date>
    </item>
    <item>
      <title>Re: cummulative variable</title>
      <link>https://communities.sas.com/t5/SAS-Programming/cummulative-variable/m-p/588759#M168314</link>
      <description>&lt;P&gt;Could you please try the below code, i used the retain statement&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data hw5a;
set hw5a.HW5a;
by week;
retain cumNsurgery;
if first.Week then cumNsurgery= Nsurgery;
else cumNsurgery + Nsurgery;
keep;
run;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Sat, 14 Sep 2019 19:48:03 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/cummulative-variable/m-p/588759#M168314</guid>
      <dc:creator>Jagadishkatam</dc:creator>
      <dc:date>2019-09-14T19:48:03Z</dc:date>
    </item>
    <item>
      <title>Re: cummulative variable</title>
      <link>https://communities.sas.com/t5/SAS-Programming/cummulative-variable/m-p/588761#M168315</link>
      <description>&lt;BLOCKQUOTE&gt;&lt;HR /&gt;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/289899"&gt;@ambreen&lt;/a&gt;&amp;nbsp;wrote:&lt;BR /&gt;
&lt;P&gt;&lt;FONT&gt;libname hw5a "C:\Users\noor\Desktop";&lt;BR /&gt;data hw5a;&lt;BR /&gt;set hw5a.HW5a;&lt;BR /&gt;by week;&lt;BR /&gt;if first.Week then cumNsurgery= Nsurgery;&lt;BR /&gt;else cumNsurgery + Nsurgery;&lt;BR /&gt;keep;&lt;BR /&gt;run;&lt;/FONT&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&lt;FONT&gt;&amp;nbsp;I am trying to create a cumulative but whats wrong with my code&lt;/FONT&gt;&lt;/P&gt;
&lt;HR /&gt;&lt;/BLOCKQUOTE&gt;
&lt;P&gt;Please post the whole log of that code. Use the {I} button for posting the log.&lt;/P&gt;</description>
      <pubDate>Sat, 14 Sep 2019 20:00:11 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/cummulative-variable/m-p/588761#M168315</guid>
      <dc:creator>Kurt_Bremser</dc:creator>
      <dc:date>2019-09-14T20:00:11Z</dc:date>
    </item>
    <item>
      <title>Re: cummulative variable</title>
      <link>https://communities.sas.com/t5/SAS-Programming/cummulative-variable/m-p/588764#M168318</link>
      <description>&lt;BLOCKQUOTE&gt;&lt;HR /&gt;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/289899"&gt;@ambreen&lt;/a&gt;&amp;nbsp;wrote:&lt;BR /&gt;
&lt;P&gt;&lt;FONT&gt;libname hw5a "C:\Users\noor\Desktop";&lt;BR /&gt;data hw5a;&lt;BR /&gt;set hw5a.HW5a;&lt;BR /&gt;by week;&lt;BR /&gt;if first.Week then cumNsurgery= Nsurgery;&lt;BR /&gt;else cumNsurgery + Nsurgery;&lt;BR /&gt;keep;&lt;BR /&gt;run;&lt;/FONT&gt;&lt;/P&gt;
&lt;HR /&gt;&lt;/BLOCKQUOTE&gt;
&lt;P&gt;If you are getting the same value, perhaps it is Nsurgery that does not have the value you expect. Have you looked at it?&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Nevertheless, don't expect us to guess what is happening; show us a portion of your data, following these instructions: &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" rel="noopener"&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>Sat, 14 Sep 2019 20:44:44 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/cummulative-variable/m-p/588764#M168318</guid>
      <dc:creator>PaigeMiller</dc:creator>
      <dc:date>2019-09-14T20:44:44Z</dc:date>
    </item>
    <item>
      <title>Re: cummulative variable</title>
      <link>https://communities.sas.com/t5/SAS-Programming/cummulative-variable/m-p/588772#M168321</link>
      <description>&lt;BLOCKQUOTE&gt;&lt;HR /&gt;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/12151"&gt;@Jagadishkatam&lt;/a&gt;&amp;nbsp;wrote:&lt;BR /&gt;
&lt;P&gt;Could you please try the below code, i used the retain statement&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data hw5a;
set hw5a.HW5a;
by week;
retain cumNsurgery;
if first.Week then cumNsurgery= Nsurgery;
else cumNsurgery + Nsurgery;
keep;
run;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;HR /&gt;&lt;/BLOCKQUOTE&gt;
&lt;P&gt;As far as I know, the RETAIN statement shouldn't make the slightest difference here. Can someone explain why it matters in this example?&lt;/P&gt;</description>
      <pubDate>Sat, 14 Sep 2019 21:36:03 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/cummulative-variable/m-p/588772#M168321</guid>
      <dc:creator>PaigeMiller</dc:creator>
      <dc:date>2019-09-14T21:36:03Z</dc:date>
    </item>
    <item>
      <title>Re: cummulative variable</title>
      <link>https://communities.sas.com/t5/SAS-Programming/cummulative-variable/m-p/588773#M168322</link>
      <description>&lt;P&gt;how can I create a cumulative variable cumN week that shows cumulative week with atleast one surgery&lt;/P&gt;</description>
      <pubDate>Sat, 14 Sep 2019 21:36:29 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/cummulative-variable/m-p/588773#M168322</guid>
      <dc:creator>ambreen</dc:creator>
      <dc:date>2019-09-14T21:36:29Z</dc:date>
    </item>
    <item>
      <title>Re: cummulative variable</title>
      <link>https://communities.sas.com/t5/SAS-Programming/cummulative-variable/m-p/588774#M168323</link>
      <description>&lt;P&gt;Hi&amp;nbsp;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/289899"&gt;@ambreen&lt;/a&gt;&amp;nbsp; &amp;nbsp;It's my humble request that you pay attention to&amp;nbsp;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/462"&gt;@PGStats&lt;/a&gt;&amp;nbsp; and&amp;nbsp;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/10892"&gt;@PaigeMiller&lt;/a&gt;&amp;nbsp; as the solution doesn't quite relate to the actual problem. Your code seems ok with or without &lt;EM&gt;&lt;STRONG&gt;redundant&lt;/STRONG&gt; &lt;/EM&gt;RETAIN considering you have used a SUM statement which is implicit retain. Therefore, that cannot be the fix. I'm afraid if you miss out on those intricate details, your result might not be what you want downstream. Well, it's up to you.&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Sat, 14 Sep 2019 21:40:09 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/cummulative-variable/m-p/588774#M168323</guid>
      <dc:creator>novinosrin</dc:creator>
      <dc:date>2019-09-14T21:40:09Z</dc:date>
    </item>
    <item>
      <title>Re: cummulative variable</title>
      <link>https://communities.sas.com/t5/SAS-Programming/cummulative-variable/m-p/588775#M168324</link>
      <description>&lt;BLOCKQUOTE&gt;&lt;HR /&gt;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/289899"&gt;@ambreen&lt;/a&gt;&amp;nbsp;wrote:&lt;BR /&gt;
&lt;P&gt;how can I create a cumulative variable cumN week that shows cumulative week with atleast one surgery&lt;/P&gt;
&lt;HR /&gt;&lt;/BLOCKQUOTE&gt;
&lt;P&gt;Show us a portion of the data you are using, following these instructions: &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" rel="noopener"&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;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;I doubt we can come up with the right answer if we can't see your data.&lt;/P&gt;</description>
      <pubDate>Sat, 14 Sep 2019 21:44:17 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/cummulative-variable/m-p/588775#M168324</guid>
      <dc:creator>PaigeMiller</dc:creator>
      <dc:date>2019-09-14T21:44:17Z</dc:date>
    </item>
    <item>
      <title>Re: cummulative variable</title>
      <link>https://communities.sas.com/t5/SAS-Programming/cummulative-variable/m-p/588779#M168325</link>
      <description>&lt;P&gt;I think the retain is required because comNsurgery is already in dataset hw5a. In that case, the sum statement being after the set statement does not imply retain.&lt;/P&gt;</description>
      <pubDate>Sat, 14 Sep 2019 22:52:17 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/cummulative-variable/m-p/588779#M168325</guid>
      <dc:creator>PGStats</dc:creator>
      <dc:date>2019-09-14T22:52:17Z</dc:date>
    </item>
    <item>
      <title>Re: cummulative variable</title>
      <link>https://communities.sas.com/t5/SAS-Programming/cummulative-variable/m-p/588791#M168331</link>
      <description>&lt;P&gt;Agree that the RETAIN statement does nothing.&amp;nbsp; Some other possibilities:&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;UL&gt;
&lt;LI&gt;If cumNSurgery is already part of the incoming data set, then it gets replaced each time the SET statement executes.&amp;nbsp; That's every time.&amp;nbsp; Perhaps it is already in the data with a value of 0.&lt;/LI&gt;
&lt;LI&gt;Perhaps WEEK is the wrong variable to use in the BY statement.&amp;nbsp; The results you are claiming to get should occur if your data has just one observation for each WEEK.&amp;nbsp; That seems to be the case with the data that you posted, so you should expect cumNSurgery to equal NSurgery when there is just a a single observation per week.&amp;nbsp; Perhaps the IF THEN logic should be replaced with simply:&lt;/LI&gt;
&lt;/UL&gt;
&lt;P&gt;cumNSurgery + NSurgery;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;At any rate, this statement should be removed:&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;keep;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Sun, 15 Sep 2019 02:46:51 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/cummulative-variable/m-p/588791#M168331</guid>
      <dc:creator>Astounding</dc:creator>
      <dc:date>2019-09-15T02:46:51Z</dc:date>
    </item>
    <item>
      <title>Re: cummulative variable</title>
      <link>https://communities.sas.com/t5/SAS-Programming/cummulative-variable/m-p/588798#M168335</link>
      <description>&lt;BLOCKQUOTE&gt;&lt;HR /&gt;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/289899"&gt;@ambreen&lt;/a&gt;&amp;nbsp;wrote:&lt;BR /&gt;
&lt;P&gt;how can I create a cumulative variable cumN week that shows cumulative week with atleast one surgery&lt;/P&gt;
&lt;HR /&gt;&lt;/BLOCKQUOTE&gt;
&lt;P&gt;Please read my previous post again.&lt;/P&gt;</description>
      <pubDate>Sun, 15 Sep 2019 05:05:08 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/cummulative-variable/m-p/588798#M168335</guid>
      <dc:creator>Kurt_Bremser</dc:creator>
      <dc:date>2019-09-15T05:05:08Z</dc:date>
    </item>
    <item>
      <title>Re: cummulative variable</title>
      <link>https://communities.sas.com/t5/SAS-Programming/cummulative-variable/m-p/589215#M168490</link>
      <description>&lt;BLOCKQUOTE&gt;&lt;HR /&gt;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/289899"&gt;@ambreen&lt;/a&gt;&amp;nbsp;wrote:&lt;BR /&gt;
&lt;P&gt;&lt;FONT&gt;libname hw5a "C:\Users\noor\Desktop";&lt;BR /&gt;data hw5a;&lt;BR /&gt;set hw5a.HW5a;&lt;BR /&gt;by week;&lt;BR /&gt;if first.Week then cumNsurgery= Nsurgery;&lt;BR /&gt;else cumNsurgery + Nsurgery;&lt;BR /&gt;keep;&lt;BR /&gt;run;&lt;/FONT&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&lt;FONT&gt;&amp;nbsp;I am trying to create a cumulative but whats wrong with my code&lt;/FONT&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&lt;FONT&gt;my data is&amp;nbsp;&lt;/FONT&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&lt;FONT&gt;week&amp;nbsp; Nsurgery&lt;/FONT&gt;&lt;/P&gt;
&lt;P&gt;&lt;FONT&gt;1 &amp;nbsp; &amp;nbsp;&amp;nbsp; 1&lt;/FONT&gt;&lt;/P&gt;
&lt;P&gt;&lt;FONT&gt;2 &amp;nbsp;&amp;nbsp; 0&lt;/FONT&gt;&lt;/P&gt;
&lt;P&gt;&lt;FONT&gt;3 &amp;nbsp; &amp;nbsp; 5&lt;/FONT&gt;&lt;/P&gt;
&lt;P&gt;&lt;FONT&gt;4 &amp;nbsp; &amp;nbsp; 7&lt;/FONT&gt;&lt;/P&gt;
&lt;P&gt;&lt;FONT&gt;5 &amp;nbsp;&amp;nbsp; 4&lt;/FONT&gt;&lt;/P&gt;
&lt;P&gt;&lt;FONT&gt;6 &amp;nbsp;&amp;nbsp; 0&lt;/FONT&gt;&lt;/P&gt;
&lt;P&gt;&lt;FONT&gt;7 &amp;nbsp;&amp;nbsp; 1&lt;/FONT&gt;&lt;/P&gt;
&lt;P&gt;&lt;FONT&gt;8 &amp;nbsp;&amp;nbsp; 3&lt;/FONT&gt;&lt;/P&gt;
&lt;P&gt;&lt;FONT&gt;9 &amp;nbsp;&amp;nbsp; 5&lt;/FONT&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;HR /&gt;&lt;/BLOCKQUOTE&gt;
&lt;P&gt;Your shown data and the attached data set only have one record with each "week" value. So every record is the first week and there is only the one nsurgery value.&lt;/P&gt;
&lt;P&gt;If you have data with multiple records for week then share.&lt;/P&gt;</description>
      <pubDate>Mon, 16 Sep 2019 23:02:22 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/cummulative-variable/m-p/589215#M168490</guid>
      <dc:creator>ballardw</dc:creator>
      <dc:date>2019-09-16T23:02:22Z</dc:date>
    </item>
  </channel>
</rss>

