<?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: How to take count against any variable in sas proc report in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/How-to-take-count-against-any-variable-in-sas-proc-report/m-p/684515#M207437</link>
    <description>&lt;P&gt;Please try:&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;proc report data=work.have;
   define date / group order=data;
   define policy_no / n;
   
   rbreak after / summarize;
run;&lt;/CODE&gt;&lt;/PRE&gt;</description>
    <pubDate>Thu, 17 Sep 2020 08:27:11 GMT</pubDate>
    <dc:creator>andreas_lds</dc:creator>
    <dc:date>2020-09-17T08:27:11Z</dc:date>
    <item>
      <title>How to take count against any variable in sas proc report</title>
      <link>https://communities.sas.com/t5/SAS-Programming/How-to-take-count-against-any-variable-in-sas-proc-report/m-p/684500#M207429</link>
      <description>&lt;P&gt;input table&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-family: inherit;"&gt;Date policy_no&lt;BR /&gt;1-Apr-20 53398314&lt;BR /&gt;1-Apr-20 53424502&lt;BR /&gt;1-Apr-20 53432609&lt;BR /&gt;1-May-20 53435311&lt;BR /&gt;1-Apr-20 53435321&lt;BR /&gt;1-Aug-20 53435707&lt;BR /&gt;1-Apr-20 53437505&lt;BR /&gt;1-Apr-20 53438590&lt;BR /&gt;1-Apr-20 53441689&lt;BR /&gt;1-Apr-20 53444668&lt;BR /&gt;1-Apr-20 53445856&lt;BR /&gt;1-May-20 53494214&lt;BR /&gt;1-May-20 53494233&lt;BR /&gt;1-May-20 53494334&lt;BR /&gt;1-May-20 53494347&lt;BR /&gt;1-May-20 53494359&lt;BR /&gt;1-May-20 53494399&lt;BR /&gt;1-May-20 53494445&lt;BR /&gt;1-May-20 53494571&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-family: inherit;"&gt;Required Output&amp;nbsp;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;TABLE&gt;&lt;TBODY&gt;&lt;TR&gt;&lt;TD&gt;Date&lt;/TD&gt;&lt;TD&gt;Count of policy_no&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD&gt;1-Apr-20&lt;/TD&gt;&lt;TD&gt;9&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD&gt;1-May-20&lt;/TD&gt;&lt;TD&gt;9&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD&gt;1-Aug-20&lt;/TD&gt;&lt;TD&gt;1&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD&gt;Grand Total&lt;/TD&gt;&lt;TD&gt;19&lt;/TD&gt;&lt;/TR&gt;&lt;/TBODY&gt;&lt;/TABLE&gt;&lt;P&gt;i want count of policies against date variable in sas proc report.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Thanks in advance for your replay.&lt;/P&gt;</description>
      <pubDate>Thu, 17 Sep 2020 04:28:08 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/How-to-take-count-against-any-variable-in-sas-proc-report/m-p/684500#M207429</guid>
      <dc:creator>Shantaram</dc:creator>
      <dc:date>2020-09-17T04:28:08Z</dc:date>
    </item>
    <item>
      <title>Re: How to take count against any variable in sas proc report</title>
      <link>https://communities.sas.com/t5/SAS-Programming/How-to-take-count-against-any-variable-in-sas-proc-report/m-p/684502#M207431</link>
      <description>&lt;P&gt;You can use next code though it's not by proc report:&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data have;
 input date date9. policy_no ;
 format date date9.;
cards;
1-Apr-20 53398314
1-Apr-20 53424502
1-Apr-20 53432609
1-May-20 53435311
1-Apr-20 53435321
1-Aug-20 53435707
1-Apr-20 53437505
1-Apr-20 53438590
1-Apr-20 53441689
1-Apr-20 53444668
1-Apr-20 53445856
1-May-20 53494214
1-May-20 53494233
1-May-20 53494334
1-May-20 53494347
1-May-20 53494359
1-May-20 53494399
1-May-20 53494445
1-May-20 53494571
; run;

proc sort data=have out=sorted nodupkey;
  by date policy_no;
 run;

data to_rep;
 set sorted;
  by date;
     retain count;
     *format date date9.;
     if first.date then count=1; else count+1;
     if last.date then output;
     drop policy_no;
run;

&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Thu, 17 Sep 2020 05:00:45 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/How-to-take-count-against-any-variable-in-sas-proc-report/m-p/684502#M207431</guid>
      <dc:creator>Shmuel</dc:creator>
      <dc:date>2020-09-17T05:00:45Z</dc:date>
    </item>
    <item>
      <title>Re: How to take count against any variable in sas proc report</title>
      <link>https://communities.sas.com/t5/SAS-Programming/How-to-take-count-against-any-variable-in-sas-proc-report/m-p/684503#M207432</link>
      <description>&lt;P&gt;Thanks Shmuel,&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I want same solution in proc report.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Thu, 17 Sep 2020 05:06:37 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/How-to-take-count-against-any-variable-in-sas-proc-report/m-p/684503#M207432</guid>
      <dc:creator>Shantaram</dc:creator>
      <dc:date>2020-09-17T05:06:37Z</dc:date>
    </item>
    <item>
      <title>Re: How to take count against any variable in sas proc report</title>
      <link>https://communities.sas.com/t5/SAS-Programming/How-to-take-count-against-any-variable-in-sas-proc-report/m-p/684504#M207433</link>
      <description>&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;proc report data=Final&lt;BR /&gt;STYLE(LINES)=[FONT=('TIMES NEW ROMAN',5PT) JUST=LEFT color=BLACK]&lt;BR /&gt;STYLE(REPORT)=[FONT=('TIMES NEW ROMAN',6PT)]&lt;BR /&gt;STYLE(HEADER)=[FONT=('Arial', 9PT, Bold) background=CX13478C fontsize=1.5 color=white]&lt;BR /&gt;STYLE(COLUMN)=[FONT=('Arial',8PT) fontsize=1.5 COLOR=BLACK ];&lt;BR /&gt;where pilot='Control';&lt;BR /&gt;column date&lt;BR /&gt;Policy_no&lt;BR /&gt;&lt;BR /&gt;;&lt;/P&gt;&lt;P&gt;define date/ group 'Due_Month';&lt;BR /&gt;define policy_no/NOPRINT;&lt;/P&gt;&lt;P&gt;define Cont_Policies/computed width=3 '# Policies' style=[tagattr="format:#,##0.00%"];&lt;BR /&gt;compute Cont_Policies;&lt;BR /&gt;/*if pilot='Control' then */&lt;BR /&gt;Cont_Policies= N(Policy_no);&lt;/P&gt;&lt;P&gt;endcomp;&lt;/P&gt;&lt;P&gt;run;&lt;BR /&gt;&lt;BR /&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Thu, 17 Sep 2020 05:20:19 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/How-to-take-count-against-any-variable-in-sas-proc-report/m-p/684504#M207433</guid>
      <dc:creator>Shantaram</dc:creator>
      <dc:date>2020-09-17T05:20:19Z</dc:date>
    </item>
    <item>
      <title>Re: How to take count against any variable in sas proc report</title>
      <link>https://communities.sas.com/t5/SAS-Programming/How-to-take-count-against-any-variable-in-sas-proc-report/m-p/684514#M207436</link>
      <description>&lt;P&gt;I have searched sas documentation for statistics available in &lt;A href="https://documentation.sas.com/?docsetId=proc&amp;amp;docsetTarget=p0bqogcics9o4xn17yvt2qjbgdpi.htm&amp;amp;docsetVersion=9.4&amp;amp;locale=en" target="_self"&gt;proc report&lt;/A&gt;.&lt;/P&gt;
&lt;P&gt;For my best understanding the only statistic built in is SUM:&lt;/P&gt;
&lt;PRE&gt;statistic
associates a statistic with an analysis variable. You must associate a statistic with every analysis variable in its definition. PROC REPORT uses the statistic that you specify to calculate values for the analysis variable for the observations that are represented by each cell of the report. You cannot use statistic in the definition of any other type of variable.
See Statistics That Are Available in PROC REPORT for a list of available statistics.

Default	SUM
Note	PROC REPORT uses the name of the analysis variable as the default heading for the column. You can customize the column heading with the column-header option in the DEFINE statement.
Examples	Ordering the Rows in a Report
Using Aliases to Obtain Multiple Statistics for the Same Variable

Consolidating Multiple Observations into One Row of a Report&lt;/PRE&gt;
&lt;P&gt;any other should be computed.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Next are 3 methods to get the wanted results, (1) by proc freq (2) by a data step (3) by proc report.&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data have;
 input date date9. policy_no ;
 format date date9.;
cards;
1-Apr-20 53398314
1-Apr-20 53424502
1-Apr-20 53432609
1-May-20 53435311
1-Apr-20 53435321
1-Aug-20 53435707
1-Apr-20 53437505
1-Apr-20 53438590
1-Apr-20 53441689
1-Apr-20 53444668
1-Apr-20 53445856
1-May-20 53494214
1-May-20 53494233
1-May-20 53494334
1-May-20 53494347
1-May-20 53494359
1-May-20 53494399
1-May-20 53494445
1-May-20 53494571
; run;

proc sort data=have out=sorted nodupkey;
  by date policy_no;
 run;
 
/* SOLUTION 1 by proc freq */
proc freq data=sorted;
  table date / out=freq(keep=date count)  
               nocol norow nocum nopercent; 
run; 
/* SOLUTION 2 by a data step */
data to_rep;
 set sorted;
  by date;
     retain count;
     
     if first.date then count=1; else count+1;
     if last.date then output;
     drop policy_no;
run;

/* SOLUTION 3 by a proc freq */
proc sort data=have;
  by date policy_no;
 run;
data sorted;
 set have;
  by date policy_no;
     if first.policy_no then Count_Policies=1;
     else Count_Policies=0;
run;

proc report data=sorted;
	column date Count_Policies /* N=Count_Policies*/;
	define date / display group 'Due_Month';
	define Count_Policies / analysis sum '# Policies';
run;

&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Thu, 17 Sep 2020 08:15:06 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/How-to-take-count-against-any-variable-in-sas-proc-report/m-p/684514#M207436</guid>
      <dc:creator>Shmuel</dc:creator>
      <dc:date>2020-09-17T08:15:06Z</dc:date>
    </item>
    <item>
      <title>Re: How to take count against any variable in sas proc report</title>
      <link>https://communities.sas.com/t5/SAS-Programming/How-to-take-count-against-any-variable-in-sas-proc-report/m-p/684515#M207437</link>
      <description>&lt;P&gt;Please try:&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;proc report data=work.have;
   define date / group order=data;
   define policy_no / n;
   
   rbreak after / summarize;
run;&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Thu, 17 Sep 2020 08:27:11 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/How-to-take-count-against-any-variable-in-sas-proc-report/m-p/684515#M207437</guid>
      <dc:creator>andreas_lds</dc:creator>
      <dc:date>2020-09-17T08:27:11Z</dc:date>
    </item>
    <item>
      <title>Re: How to take count against any variable in sas proc report</title>
      <link>https://communities.sas.com/t5/SAS-Programming/How-to-take-count-against-any-variable-in-sas-proc-report/m-p/684653#M207517</link>
      <description>&lt;P&gt;This may get you started&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;proc report data=have;
   columns date date=count;
   define date/group;
   define count /n format=best5. "Count of policy_no";
   rbreak after/summarize;
run;&lt;/PRE&gt;</description>
      <pubDate>Thu, 17 Sep 2020 15:06:11 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/How-to-take-count-against-any-variable-in-sas-proc-report/m-p/684653#M207517</guid>
      <dc:creator>ballardw</dc:creator>
      <dc:date>2020-09-17T15:06:11Z</dc:date>
    </item>
  </channel>
</rss>

