<?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 PROC REPORT WITH CONDITION in ODS and Base Reporting</title>
    <link>https://communities.sas.com/t5/ODS-and-Base-Reporting/PROC-REPORT-WITH-CONDITION/m-p/407499#M19687</link>
    <description>&lt;P&gt;I need to have a report, only need past 12&amp;nbsp; month data, is there a way from PROC Report to achieve it.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;My Code:&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 _null_;
    dMEnd=intnx('month', today(), -12, 'e');
    Call symput('dtMEnd', PUT(dMEnd, YYMMD.));
run;

%PUT &amp;amp;dtMEnd;

PROC REPORT DATA=TPLMEM.TPL_SUMMARY_0100 (MONTH &amp;gt;="&amp;amp;dtMEnd");
    COLUMN MONTH Category OVERALL_MEMBERSHIP TPL MEDICARE MEDICARE_SUPPLEMENTAL 
        MEDICARE_A MEDICARE_B MEDICARE_AB MEDICARE_ADVANTAGE COMMERCIAL VISION DENTAL 
        LIMITED_BENEFITS Casualty PHARMACY;
    DEFINE MONTH/GROUP;
    DEFINE MONTH/ORDER descending;
    title " LOB 0100 TPL Membership";
    footnote" Run at &amp;amp;sDay &amp;amp;stime";
RUN;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;The code would not working... how to ? need advise.&lt;/P&gt;</description>
    <pubDate>Thu, 26 Oct 2017 00:06:51 GMT</pubDate>
    <dc:creator>JHE</dc:creator>
    <dc:date>2017-10-26T00:06:51Z</dc:date>
    <item>
      <title>PROC REPORT WITH CONDITION</title>
      <link>https://communities.sas.com/t5/ODS-and-Base-Reporting/PROC-REPORT-WITH-CONDITION/m-p/407499#M19687</link>
      <description>&lt;P&gt;I need to have a report, only need past 12&amp;nbsp; month data, is there a way from PROC Report to achieve it.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;My Code:&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 _null_;
    dMEnd=intnx('month', today(), -12, 'e');
    Call symput('dtMEnd', PUT(dMEnd, YYMMD.));
run;

%PUT &amp;amp;dtMEnd;

PROC REPORT DATA=TPLMEM.TPL_SUMMARY_0100 (MONTH &amp;gt;="&amp;amp;dtMEnd");
    COLUMN MONTH Category OVERALL_MEMBERSHIP TPL MEDICARE MEDICARE_SUPPLEMENTAL 
        MEDICARE_A MEDICARE_B MEDICARE_AB MEDICARE_ADVANTAGE COMMERCIAL VISION DENTAL 
        LIMITED_BENEFITS Casualty PHARMACY;
    DEFINE MONTH/GROUP;
    DEFINE MONTH/ORDER descending;
    title " LOB 0100 TPL Membership";
    footnote" Run at &amp;amp;sDay &amp;amp;stime";
RUN;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;The code would not working... how to ? need advise.&lt;/P&gt;</description>
      <pubDate>Thu, 26 Oct 2017 00:06:51 GMT</pubDate>
      <guid>https://communities.sas.com/t5/ODS-and-Base-Reporting/PROC-REPORT-WITH-CONDITION/m-p/407499#M19687</guid>
      <dc:creator>JHE</dc:creator>
      <dc:date>2017-10-26T00:06:51Z</dc:date>
    </item>
    <item>
      <title>Re: PROC REPROT WITH CONDITION</title>
      <link>https://communities.sas.com/t5/ODS-and-Base-Reporting/PROC-REPORT-WITH-CONDITION/m-p/407506#M19688</link>
      <description>&lt;P&gt;You have a couple of issues, at first glance.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;1. You don't have the keyword WHERE to indicate you're trying to filter the data set.&amp;nbsp;&lt;/P&gt;
&lt;P&gt;2. Your date isn't formatted correctly, recall how SAS needs dates specified, in a DATE9 format.&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Wed, 25 Oct 2017 23:57:51 GMT</pubDate>
      <guid>https://communities.sas.com/t5/ODS-and-Base-Reporting/PROC-REPORT-WITH-CONDITION/m-p/407506#M19688</guid>
      <dc:creator>Reeza</dc:creator>
      <dc:date>2017-10-25T23:57:51Z</dc:date>
    </item>
    <item>
      <title>Re: PROC REPORT WITH CONDITION</title>
      <link>https://communities.sas.com/t5/ODS-and-Base-Reporting/PROC-REPORT-WITH-CONDITION/m-p/407509#M19689</link>
      <description>&lt;P&gt;Hi:&lt;/P&gt;
&lt;P&gt;&amp;nbsp; You may have specified your condition incorrectly. Since you did not post data, I made a few examples using SASHELP.CLASS. Use either a WHERE Statement or a WHERE dataset option.&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;%let wantage = 15;

proc report data=sashelp.class;
  title 'Where Statement';
  where age ge &amp;amp;wantage;
run;

proc report data=sashelp.class(where=(age ge &amp;amp;wantage));
  title 'Where DATASET Option';
run;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;&amp;nbsp; You are using a DATA step before your PROC REPORT to generate a character string that looks like this:&lt;/P&gt;
&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="macro_var_value.png" style="width: 402px;"&gt;&lt;img src="https://communities.sas.com/t5/image/serverpage/image-id/16225iDBA176A01470BA9C/image-size/large?v=v2&amp;amp;px=999" role="button" title="macro_var_value.png" alt="macro_var_value.png" /&gt;&lt;/span&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;So how your condition will work depends on the format of the variable MONTH in your data. Right now, you are treating the macro variable in the comparison as a text string:&lt;/P&gt;
&lt;P&gt;where month ge &lt;FONT face="Courier New" size="3"&gt;&lt;STRONG&gt;= "2016-10";&lt;/STRONG&gt;&lt;/FONT&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;if your MONTH variable is a character string in the form YYYY-MM, then once you get the WHERE specified correctly, you should get hits, if the data has observations with that value. However, if MONTH is a SAS date value, then you are specifying the WHERE condition incorrectly.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;When you do a PROC CONTENTS on the data &lt;FONT face="Courier New" size="3"&gt;TPLMEM.TPL_SUMMARY_0100&lt;/FONT&gt; what is the type for MONTH -- character or numeric. If numeric, is there a SAS date format associated with the variable?&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp; If MONTH is a standard date variable, containing a number that represents the number of days since Jan 1, 1960, then a better way to write the WHERE is to use the date constant representation of the date, as shown in the code below:&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;
data testdata;
  infile datalines;
  input month : mmddyy10. name $ amount;
return;
datalines;
04/15/2016 alan 100
08/17/2016 barb 200
10/02/2017 carl 300
11/15/2017 dana 400
04/12/2017 arla 100
08/15/2017 bill 200
10/05/2017 cathy 300
11/29/2017 dave 400
;
run;

proc report data=testdata;
  where month ge "01Oct2016"d;
  define month / group f=yymmd8.;
run;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp; Hope this helps,&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Cynthia&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Thu, 26 Oct 2017 00:16:59 GMT</pubDate>
      <guid>https://communities.sas.com/t5/ODS-and-Base-Reporting/PROC-REPORT-WITH-CONDITION/m-p/407509#M19689</guid>
      <dc:creator>Cynthia_sas</dc:creator>
      <dc:date>2017-10-26T00:16:59Z</dc:date>
    </item>
    <item>
      <title>Re: PROC REPORT WITH CONDITION</title>
      <link>https://communities.sas.com/t5/ODS-and-Base-Reporting/PROC-REPORT-WITH-CONDITION/m-p/408746#M19721</link>
      <description>&lt;P&gt;this works. Thank you&lt;/P&gt;</description>
      <pubDate>Mon, 30 Oct 2017 15:29:03 GMT</pubDate>
      <guid>https://communities.sas.com/t5/ODS-and-Base-Reporting/PROC-REPORT-WITH-CONDITION/m-p/408746#M19721</guid>
      <dc:creator>JHE</dc:creator>
      <dc:date>2017-10-30T15:29:03Z</dc:date>
    </item>
  </channel>
</rss>

