<?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 how to eliminate zeros and Duplicate date values from reporting in ODS and Base Reporting</title>
    <link>https://communities.sas.com/t5/ODS-and-Base-Reporting/Proc-report-how-to-eliminate-zeros-and-Duplicate-date-values/m-p/914993#M26483</link>
    <description>&lt;P&gt;You want to aggregate all obs for each PLANT/DATE combination, so change them from&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;define plant/display center "Plant";
define Date/display "Date";&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;to&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;define plant/group center "Plant";
define Date/group "Date";&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;and change the variables to aggregate (i.e. to sum) from&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;define Vol/display right "Vol";
define Cum_vol/display  right "Cumulative Volume";&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;to&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;define Vol/sum right "Vol";
define Cum_vol/sum  right "Cumulative Volume";&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;But the result is not in the date order you want, in part because you have DATE as a character variable. DATE needs to be a numeric variable (with a date format), which is done in the DATA HAVE step below.&amp;nbsp; &amp;nbsp;Then the report can request date in its internal order (i.e. calendar order).&amp;nbsp; That's done below.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data have;	
  infile datalines dlm=',';
  input Date_text:$10. Year 11-15 Class $16-19 Plant $21-31 vol 7.0  Cum_vol;
  date=input(compress(date_text,'-'),date7.);
  format date date9. ;
datalines;
31-Jan-24 2024 CEMI	B             45.5    45.5
01-Feb-24 2024 CEMI	B             54.8   100.3
31-Jan-24 2024 CERI	B             13.5    13.5
01-Feb-24 2024 CENI	B              6.5     6.5
05-Feb-24 2024 CEMI	B             26      26
06-Feb-24 2024 CEMI	B            137     163
31-Jan-24 2024 CENI	B            139     139
01-Feb-24 2024 CESI	B            260.5   260.5
02-Feb-24 2024 CEMI	B            184     184
run;

options missing = 0;
proc report data=have split="*";
/*    List columns to be used in the report;*/
column Date Year plant Class, (vol cum_vol) ;
define class/across "Class";
define plant/group center "Plant";&lt;BR /&gt;define Date/group order=internal "Date";&lt;BR /&gt;  define year/group;   /*Added to avoid treating YEAR as an analysis varible*/
define Vol/sum right "Vol";
define Cum_vol/sum  right "Cumulative Volume";
run;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;I speak as a neophyte in PROC REPORT, so there may be some better explanations and revisions to come.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Additional notes.&amp;nbsp; The&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;date=input(compress(date_text,'-'),date7.);&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;uses the DATE7 informat because the dates use 2-digit years (bad practice).&amp;nbsp; The default (on my SAS system) is to interpret all two-digit years from 00 through 25 are assigned to the 21st century (i.e. 2000 through 2025.&amp;nbsp; 26 through 99 go to the 20th century.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;You can control this with the yearcutoff option, as in&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;options yearcutoff=1951;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;which will assigned 00 through 50 to the 21st century.&amp;nbsp; This is an easy way to process two-digit years, but you'll probably be better off using the YEAR variable to generate DATE.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;I also define YEAR as a group variable, to avoid it being treated as analysis variable.&lt;/P&gt;</description>
    <pubDate>Thu, 08 Feb 2024 12:55:29 GMT</pubDate>
    <dc:creator>mkeintz</dc:creator>
    <dc:date>2024-02-08T12:55:29Z</dc:date>
    <item>
      <title>Proc report how to eliminate zeros and Duplicate date values from reporting</title>
      <link>https://communities.sas.com/t5/ODS-and-Base-Reporting/Proc-report-how-to-eliminate-zeros-and-Duplicate-date-values/m-p/914990#M26482</link>
      <description>&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Hi,&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;I am using below prog. to output a report in excel using proc report.&amp;nbsp;&lt;/P&gt;
&lt;P&gt;As you can see from attachments current output has zero and duplicate dates.&lt;/P&gt;
&lt;P&gt;How can i bring 4th row 01Feb2024&amp;nbsp; data from CENI class to 2nd row(as shown in expected output image attached). Similarly, 7th row 31Jan2024 CENI date to 1st row in CENI class.&lt;/P&gt;
&lt;P&gt;And based on date variable how can i insert Year value as shown in expected output file.&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;

data have;	
	infile datalines dlm=',';
		input Date:$10. Year 11-15 Class $16-19 Plant $21-31 vol 32-39  Cum_vol;
datalines;
31-Jan-24 2024 CEMI	B 	        45.5	 45.5
01-Feb-24 2024 CEMI	B 	        54.8	100.3
31-Jan-24 2024 CERI	B	        13.5	 13.5
01-Feb-24 2024 CENI	B	         6.5	  6.5
05-Feb-24 2024 CEMI	B	          26	   26
06-Feb-24 2024 CEMI	B	         137	  163
31-Jan-24 2024 CENI	B       	 139	  139
01-Feb-24 2024 CESI	B          260.5	260.5
02-Feb-24 2024 CEMI	B            184	  184
;
run;

options missing = 0;
proc report data=have split="*";
/*    List columns to be used in the report;*/
column Date Year plant Class, (vol cum_vol);
define class/across "Class";
define plant/display center "Plant";
define Date/display "Date";
define Vol/display right "Vol";
define Cum_vol/display  right "Cumulative Volume";
run;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;Current output&lt;/P&gt;
&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="current output.jpg" style="width: 400px;"&gt;&lt;img src="https://communities.sas.com/t5/image/serverpage/image-id/93367iCC77CC48C2EA1173/image-size/medium?v=v2&amp;amp;px=400" role="button" title="current output.jpg" alt="current output.jpg" /&gt;&lt;/span&gt;&lt;/P&gt;
&lt;P&gt;Expected output&lt;/P&gt;
&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="expected output.jpg" style="width: 400px;"&gt;&lt;img src="https://communities.sas.com/t5/image/serverpage/image-id/93368i6ADCED30EFCD3745/image-size/medium?v=v2&amp;amp;px=400" role="button" title="expected output.jpg" alt="expected output.jpg" /&gt;&lt;/span&gt;&lt;/P&gt;
&lt;P&gt;  &lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Thu, 08 Feb 2024 01:24:42 GMT</pubDate>
      <guid>https://communities.sas.com/t5/ODS-and-Base-Reporting/Proc-report-how-to-eliminate-zeros-and-Duplicate-date-values/m-p/914990#M26482</guid>
      <dc:creator>vnreddy</dc:creator>
      <dc:date>2024-02-08T01:24:42Z</dc:date>
    </item>
    <item>
      <title>Re: Proc report how to eliminate zeros and Duplicate date values from reporting</title>
      <link>https://communities.sas.com/t5/ODS-and-Base-Reporting/Proc-report-how-to-eliminate-zeros-and-Duplicate-date-values/m-p/914993#M26483</link>
      <description>&lt;P&gt;You want to aggregate all obs for each PLANT/DATE combination, so change them from&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;define plant/display center "Plant";
define Date/display "Date";&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;to&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;define plant/group center "Plant";
define Date/group "Date";&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;and change the variables to aggregate (i.e. to sum) from&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;define Vol/display right "Vol";
define Cum_vol/display  right "Cumulative Volume";&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;to&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;define Vol/sum right "Vol";
define Cum_vol/sum  right "Cumulative Volume";&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;But the result is not in the date order you want, in part because you have DATE as a character variable. DATE needs to be a numeric variable (with a date format), which is done in the DATA HAVE step below.&amp;nbsp; &amp;nbsp;Then the report can request date in its internal order (i.e. calendar order).&amp;nbsp; That's done below.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data have;	
  infile datalines dlm=',';
  input Date_text:$10. Year 11-15 Class $16-19 Plant $21-31 vol 7.0  Cum_vol;
  date=input(compress(date_text,'-'),date7.);
  format date date9. ;
datalines;
31-Jan-24 2024 CEMI	B             45.5    45.5
01-Feb-24 2024 CEMI	B             54.8   100.3
31-Jan-24 2024 CERI	B             13.5    13.5
01-Feb-24 2024 CENI	B              6.5     6.5
05-Feb-24 2024 CEMI	B             26      26
06-Feb-24 2024 CEMI	B            137     163
31-Jan-24 2024 CENI	B            139     139
01-Feb-24 2024 CESI	B            260.5   260.5
02-Feb-24 2024 CEMI	B            184     184
run;

options missing = 0;
proc report data=have split="*";
/*    List columns to be used in the report;*/
column Date Year plant Class, (vol cum_vol) ;
define class/across "Class";
define plant/group center "Plant";&lt;BR /&gt;define Date/group order=internal "Date";&lt;BR /&gt;  define year/group;   /*Added to avoid treating YEAR as an analysis varible*/
define Vol/sum right "Vol";
define Cum_vol/sum  right "Cumulative Volume";
run;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;I speak as a neophyte in PROC REPORT, so there may be some better explanations and revisions to come.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Additional notes.&amp;nbsp; The&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;date=input(compress(date_text,'-'),date7.);&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;uses the DATE7 informat because the dates use 2-digit years (bad practice).&amp;nbsp; The default (on my SAS system) is to interpret all two-digit years from 00 through 25 are assigned to the 21st century (i.e. 2000 through 2025.&amp;nbsp; 26 through 99 go to the 20th century.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;You can control this with the yearcutoff option, as in&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;options yearcutoff=1951;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;which will assigned 00 through 50 to the 21st century.&amp;nbsp; This is an easy way to process two-digit years, but you'll probably be better off using the YEAR variable to generate DATE.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;I also define YEAR as a group variable, to avoid it being treated as analysis variable.&lt;/P&gt;</description>
      <pubDate>Thu, 08 Feb 2024 12:55:29 GMT</pubDate>
      <guid>https://communities.sas.com/t5/ODS-and-Base-Reporting/Proc-report-how-to-eliminate-zeros-and-Duplicate-date-values/m-p/914993#M26483</guid>
      <dc:creator>mkeintz</dc:creator>
      <dc:date>2024-02-08T12:55:29Z</dc:date>
    </item>
    <item>
      <title>Re: Proc report how to eliminate zeros and Duplicate date values from reporting</title>
      <link>https://communities.sas.com/t5/ODS-and-Base-Reporting/Proc-report-how-to-eliminate-zeros-and-Duplicate-date-values/m-p/915023#M26484</link>
      <description>&lt;P&gt;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/31461"&gt;@mkeintz&lt;/a&gt;&amp;nbsp;Thank you for the help.&amp;nbsp;&lt;/P&gt;
&lt;P&gt;It did work, as i expected.&amp;nbsp;&lt;/P&gt;
&lt;P&gt;How can i get the Year in output as shown in my expected output.&lt;/P&gt;</description>
      <pubDate>Thu, 08 Feb 2024 11:31:07 GMT</pubDate>
      <guid>https://communities.sas.com/t5/ODS-and-Base-Reporting/Proc-report-how-to-eliminate-zeros-and-Duplicate-date-values/m-p/915023#M26484</guid>
      <dc:creator>vnreddy</dc:creator>
      <dc:date>2024-02-08T11:31:07Z</dc:date>
    </item>
    <item>
      <title>Re: Proc report how to eliminate zeros and Duplicate date values from reporting</title>
      <link>https://communities.sas.com/t5/ODS-and-Base-Reporting/Proc-report-how-to-eliminate-zeros-and-Duplicate-date-values/m-p/915029#M26485</link>
      <description>&lt;BLOCKQUOTE&gt;&lt;HR /&gt;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/301412"&gt;@vnreddy&lt;/a&gt;&amp;nbsp;wrote:&lt;BR /&gt;
&lt;P&gt;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/31461"&gt;@mkeintz&lt;/a&gt;&amp;nbsp;Thank you for the help.&amp;nbsp;&lt;/P&gt;
&lt;P&gt;It did work, as i expected.&amp;nbsp;&lt;/P&gt;
&lt;P&gt;How can i get the Year in output as shown in my expected output.&lt;/P&gt;
&lt;HR /&gt;&lt;/BLOCKQUOTE&gt;
&lt;P&gt;I have added a define YEAR as a group variable (so it would not be summed liked the VOL variable).&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;But you will need more experienced PROC REPORT users than me to determined how to "stack" YEAR over the DATE and PLANT variables.&lt;/P&gt;</description>
      <pubDate>Thu, 08 Feb 2024 12:58:59 GMT</pubDate>
      <guid>https://communities.sas.com/t5/ODS-and-Base-Reporting/Proc-report-how-to-eliminate-zeros-and-Duplicate-date-values/m-p/915029#M26485</guid>
      <dc:creator>mkeintz</dc:creator>
      <dc:date>2024-02-08T12:58:59Z</dc:date>
    </item>
  </channel>
</rss>

