<?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: PROC REPORT with Cumulative counts in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/PROC-REPORT-with-Cumulative-counts/m-p/774775#M246268</link>
    <description>&lt;P&gt;Thank you so much for your help; I appreciate it so much!!! The code worked after I corrected the incorrect order and the incorrect usage of computation variables.&lt;/P&gt;</description>
    <pubDate>Sun, 17 Oct 2021 23:30:07 GMT</pubDate>
    <dc:creator>anonymous_user</dc:creator>
    <dc:date>2021-10-17T23:30:07Z</dc:date>
    <item>
      <title>PROC REPORT with Cumulative counts</title>
      <link>https://communities.sas.com/t5/SAS-Programming/PROC-REPORT-with-Cumulative-counts/m-p/773821#M245884</link>
      <description>&lt;P&gt;I'm trying to use PROC report to manipulate a dataset where I counted how many patients were abstinent from smoking for a certain number of 'months' (derived from dividing days by 30) . However, I also need to add a column where I find out how many patients were&amp;nbsp;&lt;STRONG&gt;not&lt;/STRONG&gt; abstinent from smoking (by subtracting the&amp;nbsp;&lt;EM&gt;cumulative&lt;/EM&gt; total of abstinent patients from the total amount of patients, 234).&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;I added a 'tmp' variable and initialized it to 0 b/c I know it resets the count, but either I've been staring at this too long or my brain's fried b/c I'm blanking on how to get my desired column:&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;
data imp55a;
	set ch4.imp55;
	Days_new=input(put(Day_abs,dayssmoke.),3.);
	Days_newish=ceil(Day_abs/30);
	
proc report data=imp55a;
	column Days_newish ID new n;
	define Days_newish / group 'Month Resumed';
	define ID / analysis n 'Not abstinent';
	define n / 'Count';
	define new / computed 'Remaining abstinent';
	compute before Days_newish;
	tmp=0;
	endcomp;
	compute new;
	new=234+-1*n;
	endcomp;

&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;Thank you guys for your kindness &amp;amp; support---I appreciate it so much!&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Wed, 13 Oct 2021 04:15:43 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/PROC-REPORT-with-Cumulative-counts/m-p/773821#M245884</guid>
      <dc:creator>anonymous_user</dc:creator>
      <dc:date>2021-10-13T04:15:43Z</dc:date>
    </item>
    <item>
      <title>Re: PROC REPORT with Cumulative counts</title>
      <link>https://communities.sas.com/t5/SAS-Programming/PROC-REPORT-with-Cumulative-counts/m-p/773858#M245892</link>
      <description>&lt;P&gt;To see what your code really does, we also ned to see the PROC FORMAT for dayssmoke.&lt;/P&gt;</description>
      <pubDate>Wed, 13 Oct 2021 08:27:21 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/PROC-REPORT-with-Cumulative-counts/m-p/773858#M245892</guid>
      <dc:creator>Kurt_Bremser</dc:creator>
      <dc:date>2021-10-13T08:27:21Z</dc:date>
    </item>
    <item>
      <title>Re: PROC REPORT with Cumulative counts</title>
      <link>https://communities.sas.com/t5/SAS-Programming/PROC-REPORT-with-Cumulative-counts/m-p/773974#M245942</link>
      <description>&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;proc format;
	value dayssmoke 
	0-30 ='1' 
	31-60='2'
	61-90 ='3' 
	91-120='4'
	121-150 ='5' 
	151-180='6'
	181-210 ='7' 
	211-240='8'
	241-270 ='9' 
	271-300='10'
	301-330 ='11' 
	331-365='12'
	;
run;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;Thank you for your input; I didn't include it because I used the alternative (ceiling/division).&lt;/P&gt;</description>
      <pubDate>Wed, 13 Oct 2021 16:13:02 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/PROC-REPORT-with-Cumulative-counts/m-p/773974#M245942</guid>
      <dc:creator>anonymous_user</dc:creator>
      <dc:date>2021-10-13T16:13:02Z</dc:date>
    </item>
    <item>
      <title>Re: PROC REPORT with Cumulative counts</title>
      <link>https://communities.sas.com/t5/SAS-Programming/PROC-REPORT-with-Cumulative-counts/m-p/774129#M245984</link>
      <description>&lt;P&gt;A computed column can only use variables that have been named before them in the COLUMN statement, so new can't use n as that comes later.&lt;/P&gt;
&lt;P&gt;I moved n before new and made it noprint, as it is redundant (same values as not abstinent):&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;proc report data=imp55a;
column Days_newish ID n new;
define Days_newish / group 'Month Resumed';
define ID / analysis n 'Not abstinent';
define n / noprint;
define new / computed 'Remaining abstinent';
compute before;
all = 234;
endcomp;
compute new;
new = all - n;
endcomp;
compute after days_newish;
all = all - n;
endcomp;
run;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;Result:&lt;/P&gt;
&lt;PRE&gt;Month Resumed	Not abstinent	Remaining abstinent
0	13	221
1	139	82
2	18	64
3	10	54
4	3	51
5	5	46
6	3	43
7	2	41
8	2	39
9	3	36
11	2	34
12	1	33
13	33	0
&lt;/PRE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Thu, 14 Oct 2021 07:13:15 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/PROC-REPORT-with-Cumulative-counts/m-p/774129#M245984</guid>
      <dc:creator>Kurt_Bremser</dc:creator>
      <dc:date>2021-10-14T07:13:15Z</dc:date>
    </item>
    <item>
      <title>Re: PROC REPORT with Cumulative counts</title>
      <link>https://communities.sas.com/t5/SAS-Programming/PROC-REPORT-with-Cumulative-counts/m-p/774775#M246268</link>
      <description>&lt;P&gt;Thank you so much for your help; I appreciate it so much!!! The code worked after I corrected the incorrect order and the incorrect usage of computation variables.&lt;/P&gt;</description>
      <pubDate>Sun, 17 Oct 2021 23:30:07 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/PROC-REPORT-with-Cumulative-counts/m-p/774775#M246268</guid>
      <dc:creator>anonymous_user</dc:creator>
      <dc:date>2021-10-17T23:30:07Z</dc:date>
    </item>
  </channel>
</rss>

