<?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: Is this code counting frequency in 12 months? Can someone explain how it works? in SAS Enterprise Guide</title>
    <link>https://communities.sas.com/t5/SAS-Enterprise-Guide/Is-this-code-counting-frequency-in-12-months-Can-someone-explain/m-p/849116#M41851</link>
    <description>&lt;P&gt;No.&lt;/P&gt;
&lt;P&gt;It is counting the number of observations from the beginning of last year.&lt;/P&gt;
&lt;P&gt;So if the macro variable DT has a string like, 12DEC2022, that the DATE informat can interpret as a date in the year 2022 it counts from the beginning of 2021.&lt;/P&gt;
&lt;PRE&gt;2031  data _null_;
2032    dt='12DEC2022';
2033    date = input(dt,date11.);
2034    index=intnx('year',date,-1);
2035    put (date index) (=date9.);
2036  run;

date=12DEC2022 index=01JAN2021
&lt;/PRE&gt;</description>
    <pubDate>Mon, 12 Dec 2022 15:15:35 GMT</pubDate>
    <dc:creator>Tom</dc:creator>
    <dc:date>2022-12-12T15:15:35Z</dc:date>
    <item>
      <title>Is this code counting frequency in 12 months? Can someone explain how it works?</title>
      <link>https://communities.sas.com/t5/SAS-Enterprise-Guide/Is-this-code-counting-frequency-in-12-months-Can-someone-explain/m-p/849115#M41850</link>
      <description>&lt;P&gt;PROC SQL;&lt;BR /&gt;CREATE TABLE WORK.Retailer_Frequency_Insval AS&lt;BR /&gt;SELECT t1.retailer,&lt;BR /&gt;(COUNT(t1.retailer)) AS Retailer_Frequency&lt;BR /&gt;FROM SASDATA.insval_history t1&lt;BR /&gt;WHERE t1.date &amp;gt;= (intnx('year', "&amp;amp;DT."d, -1))&lt;BR /&gt;GROUP BY t1.retailer&lt;BR /&gt;ORDER BY t1.retailer;&lt;BR /&gt;QUIT;&lt;/P&gt;</description>
      <pubDate>Mon, 12 Dec 2022 14:58:14 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Enterprise-Guide/Is-this-code-counting-frequency-in-12-months-Can-someone-explain/m-p/849115#M41850</guid>
      <dc:creator>Sofiya</dc:creator>
      <dc:date>2022-12-12T14:58:14Z</dc:date>
    </item>
    <item>
      <title>Re: Is this code counting frequency in 12 months? Can someone explain how it works?</title>
      <link>https://communities.sas.com/t5/SAS-Enterprise-Guide/Is-this-code-counting-frequency-in-12-months-Can-someone-explain/m-p/849116#M41851</link>
      <description>&lt;P&gt;No.&lt;/P&gt;
&lt;P&gt;It is counting the number of observations from the beginning of last year.&lt;/P&gt;
&lt;P&gt;So if the macro variable DT has a string like, 12DEC2022, that the DATE informat can interpret as a date in the year 2022 it counts from the beginning of 2021.&lt;/P&gt;
&lt;PRE&gt;2031  data _null_;
2032    dt='12DEC2022';
2033    date = input(dt,date11.);
2034    index=intnx('year',date,-1);
2035    put (date index) (=date9.);
2036  run;

date=12DEC2022 index=01JAN2021
&lt;/PRE&gt;</description>
      <pubDate>Mon, 12 Dec 2022 15:15:35 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Enterprise-Guide/Is-this-code-counting-frequency-in-12-months-Can-someone-explain/m-p/849116#M41851</guid>
      <dc:creator>Tom</dc:creator>
      <dc:date>2022-12-12T15:15:35Z</dc:date>
    </item>
    <item>
      <title>Re: Is this code counting frequency in 12 months? Can someone explain how it works?</title>
      <link>https://communities.sas.com/t5/SAS-Enterprise-Guide/Is-this-code-counting-frequency-in-12-months-Can-someone-explain/m-p/849117#M41852</link>
      <description>&lt;P&gt;It depends on the contents of macro variable DT. The code will summarize from 1 year before DT up to the max date in the dataset.&lt;/P&gt;</description>
      <pubDate>Mon, 12 Dec 2022 15:16:40 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Enterprise-Guide/Is-this-code-counting-frequency-in-12-months-Can-someone-explain/m-p/849117#M41852</guid>
      <dc:creator>Kurt_Bremser</dc:creator>
      <dc:date>2022-12-12T15:16:40Z</dc:date>
    </item>
    <item>
      <title>Re: Is this code counting frequency in 12 months? Can someone explain how it works?</title>
      <link>https://communities.sas.com/t5/SAS-Enterprise-Guide/Is-this-code-counting-frequency-in-12-months-Can-someone-explain/m-p/849118#M41853</link>
      <description>&lt;P&gt;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/159"&gt;@Tom&lt;/a&gt;&amp;nbsp;, wouldn't it be the number of non-missing values of&amp;nbsp;&lt;SPAN&gt;t1.retailer since the beginning of last year?&lt;/SPAN&gt;&lt;/P&gt;</description>
      <pubDate>Mon, 12 Dec 2022 15:18:15 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Enterprise-Guide/Is-this-code-counting-frequency-in-12-months-Can-someone-explain/m-p/849118#M41853</guid>
      <dc:creator>PeterClemmensen</dc:creator>
      <dc:date>2022-12-12T15:18:15Z</dc:date>
    </item>
    <item>
      <title>Re: Is this code counting frequency in 12 months? Can someone explain how it works?</title>
      <link>https://communities.sas.com/t5/SAS-Enterprise-Guide/Is-this-code-counting-frequency-in-12-months-Can-someone-explain/m-p/849120#M41854</link>
      <description>&lt;P&gt;So, it is going to count number of observation for last 12 months even we will be in 2023, right? Is this correct way to count number of observation for the reports?&lt;/P&gt;</description>
      <pubDate>Mon, 12 Dec 2022 15:21:03 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Enterprise-Guide/Is-this-code-counting-frequency-in-12-months-Can-someone-explain/m-p/849120#M41854</guid>
      <dc:creator>Sofiya</dc:creator>
      <dc:date>2022-12-12T15:21:03Z</dc:date>
    </item>
    <item>
      <title>Re: Is this code counting frequency in 12 months? Can someone explain how it works?</title>
      <link>https://communities.sas.com/t5/SAS-Enterprise-Guide/Is-this-code-counting-frequency-in-12-months-Can-someone-explain/m-p/849130#M41857</link>
      <description>&lt;P&gt;Since retailer is also the group variable, its count will be equal to the number of observations, except for the one group where retailer is missing (if such exists at all).&lt;/P&gt;</description>
      <pubDate>Mon, 12 Dec 2022 16:00:54 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Enterprise-Guide/Is-this-code-counting-frequency-in-12-months-Can-someone-explain/m-p/849130#M41857</guid>
      <dc:creator>Kurt_Bremser</dc:creator>
      <dc:date>2022-12-12T16:00:54Z</dc:date>
    </item>
    <item>
      <title>Re: Is this code counting frequency in 12 months? Can someone explain how it works?</title>
      <link>https://communities.sas.com/t5/SAS-Enterprise-Guide/Is-this-code-counting-frequency-in-12-months-Can-someone-explain/m-p/849131#M41858</link>
      <description>&lt;P&gt;Not for the last 12 months. If run with today's date, it would count all observations for 24 months (January 2021 to December 2022).&lt;/P&gt;</description>
      <pubDate>Mon, 12 Dec 2022 16:03:24 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Enterprise-Guide/Is-this-code-counting-frequency-in-12-months-Can-someone-explain/m-p/849131#M41858</guid>
      <dc:creator>Kurt_Bremser</dc:creator>
      <dc:date>2022-12-12T16:03:24Z</dc:date>
    </item>
    <item>
      <title>Re: Is this code counting frequency in 12 months? Can someone explain how it works?</title>
      <link>https://communities.sas.com/t5/SAS-Enterprise-Guide/Is-this-code-counting-frequency-in-12-months-Can-someone-explain/m-p/849135#M41859</link>
      <description>&lt;P&gt;Ohh I see. That was my concern. What can I do to run only last 12months from today?&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;For example, today is 12/22/22, I believe it should be counting the records from 12/13/2021 to 12/12/2022 which would be 12 months of data.&lt;/SPAN&gt;&lt;/P&gt;</description>
      <pubDate>Mon, 12 Dec 2022 16:08:13 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Enterprise-Guide/Is-this-code-counting-frequency-in-12-months-Can-someone-explain/m-p/849135#M41859</guid>
      <dc:creator>Sofiya</dc:creator>
      <dc:date>2022-12-12T16:08:13Z</dc:date>
    </item>
    <item>
      <title>Re: Is this code counting frequency in 12 months? Can someone explain how it works?</title>
      <link>https://communities.sas.com/t5/SAS-Enterprise-Guide/Is-this-code-counting-frequency-in-12-months-Can-someone-explain/m-p/849146#M41860</link>
      <description>&lt;BLOCKQUOTE&gt;&lt;HR /&gt;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/437668"&gt;@Sofiya&lt;/a&gt;&amp;nbsp;wrote:&lt;BR /&gt;
&lt;P&gt;So, it is going to count number of observation for last 12 months even we will be in 2023, right? Is this correct way to count number of observation for the reports?&lt;/P&gt;
&lt;HR /&gt;&lt;/BLOCKQUOTE&gt;
&lt;P&gt;It depends.&lt;/P&gt;
&lt;P&gt;1) What is the value of the DT macro variable?&amp;nbsp; Where is that set?&amp;nbsp; What value does it have?&lt;/P&gt;
&lt;P&gt;2) What is the range of dates in the dataset?&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;If you want to count 12 months then say so explicitly in the code.&lt;/P&gt;
&lt;P&gt;Something like:&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;where datevar between intnx('year',"&amp;amp;dt"d,-1,'s') and "&amp;amp;dt"d&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Mon, 12 Dec 2022 16:37:30 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Enterprise-Guide/Is-this-code-counting-frequency-in-12-months-Can-someone-explain/m-p/849146#M41860</guid>
      <dc:creator>Tom</dc:creator>
      <dc:date>2022-12-12T16:37:30Z</dc:date>
    </item>
    <item>
      <title>Re: Is this code counting frequency in 12 months? Can someone explain how it works?</title>
      <link>https://communities.sas.com/t5/SAS-Enterprise-Guide/Is-this-code-counting-frequency-in-12-months-Can-someone-explain/m-p/849219#M41861</link>
      <description>&lt;P&gt;Where can i find&amp;nbsp;micro variable location? I went to Tools -&amp;gt; SAS micro variable viewers -&amp;gt;&amp;nbsp; searched there, but I could not find the date variable. Is there is another way to find?&lt;/P&gt;&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="Sofiya_0-1670870397138.png" style="width: 400px;"&gt;&lt;img src="https://communities.sas.com/t5/image/serverpage/image-id/78402iD8015CD1C71FDF51/image-size/medium?v=v2&amp;amp;px=400" role="button" title="Sofiya_0-1670870397138.png" alt="Sofiya_0-1670870397138.png" /&gt;&lt;/span&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Mon, 12 Dec 2022 18:40:57 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Enterprise-Guide/Is-this-code-counting-frequency-in-12-months-Can-someone-explain/m-p/849219#M41861</guid>
      <dc:creator>Sofiya</dc:creator>
      <dc:date>2022-12-12T18:40:57Z</dc:date>
    </item>
    <item>
      <title>Re: Is this code counting frequency in 12 months? Can someone explain how it works?</title>
      <link>https://communities.sas.com/t5/SAS-Enterprise-Guide/Is-this-code-counting-frequency-in-12-months-Can-someone-explain/m-p/849230#M41862</link>
      <description>&lt;P&gt;Then you do this:&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;proc sql;
create table work.Retailer_Frequency_Insval as
  select
    t1.retailer,
    (count(t1.retailer)) as Retailer_Frequency
  from sasdata.insval_history t1
  where t1.date &amp;gt; intnx('year',today(),-1,'s')
  group by t1.retailer
;
quit;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;ORDER BY is not necessary, as GROUP BY will result in a sorted order already.&lt;/P&gt;</description>
      <pubDate>Mon, 12 Dec 2022 19:21:23 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Enterprise-Guide/Is-this-code-counting-frequency-in-12-months-Can-someone-explain/m-p/849230#M41862</guid>
      <dc:creator>Kurt_Bremser</dc:creator>
      <dc:date>2022-12-12T19:21:23Z</dc:date>
    </item>
    <item>
      <title>Re: Is this code counting frequency in 12 months? Can someone explain how it works?</title>
      <link>https://communities.sas.com/t5/SAS-Enterprise-Guide/Is-this-code-counting-frequency-in-12-months-Can-someone-explain/m-p/849258#M41864</link>
      <description>&lt;P&gt;Tom, I can not see the result. It created the table but there is no value in it.&lt;/P&gt;</description>
      <pubDate>Mon, 12 Dec 2022 21:18:45 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Enterprise-Guide/Is-this-code-counting-frequency-in-12-months-Can-someone-explain/m-p/849258#M41864</guid>
      <dc:creator>Sofiya</dc:creator>
      <dc:date>2022-12-12T21:18:45Z</dc:date>
    </item>
    <item>
      <title>Re: Is this code counting frequency in 12 months? Can someone explain how it works?</title>
      <link>https://communities.sas.com/t5/SAS-Enterprise-Guide/Is-this-code-counting-frequency-in-12-months-Can-someone-explain/m-p/849261#M41865</link>
      <description>&lt;P&gt;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/11562"&gt;@Kurt_Bremser&lt;/a&gt;, I ran the code but I&lt;SPAN&gt;&amp;nbsp;can not see the result. It created the table but there is no value in it.&lt;/SPAN&gt;&lt;/P&gt;</description>
      <pubDate>Mon, 12 Dec 2022 21:26:09 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Enterprise-Guide/Is-this-code-counting-frequency-in-12-months-Can-someone-explain/m-p/849261#M41865</guid>
      <dc:creator>Sofiya</dc:creator>
      <dc:date>2022-12-12T21:26:09Z</dc:date>
    </item>
    <item>
      <title>Re: Is this code counting frequency in 12 months? Can someone explain how it works?</title>
      <link>https://communities.sas.com/t5/SAS-Enterprise-Guide/Is-this-code-counting-frequency-in-12-months-Can-someone-explain/m-p/849262#M41866</link>
      <description>&lt;P&gt;Make sure that the variable you are filtering on (T1.DATE) is actually a DATE variable.&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Make sure that the time period you want is actually there.&amp;nbsp; Try doing a quick check:&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;proc freq data=sasdata.insval_history ;
  tables date ;
  format date year4. ;
run;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Mon, 12 Dec 2022 21:30:20 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Enterprise-Guide/Is-this-code-counting-frequency-in-12-months-Can-someone-explain/m-p/849262#M41866</guid>
      <dc:creator>Tom</dc:creator>
      <dc:date>2022-12-12T21:30:20Z</dc:date>
    </item>
    <item>
      <title>Re: Is this code counting frequency in 12 months? Can someone explain how it works?</title>
      <link>https://communities.sas.com/t5/SAS-Enterprise-Guide/Is-this-code-counting-frequency-in-12-months-Can-someone-explain/m-p/849263#M41867</link>
      <description>&lt;P&gt;I can't find the date variable. Where I should go to check it?&lt;/P&gt;</description>
      <pubDate>Mon, 12 Dec 2022 21:36:04 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Enterprise-Guide/Is-this-code-counting-frequency-in-12-months-Can-someone-explain/m-p/849263#M41867</guid>
      <dc:creator>Sofiya</dc:creator>
      <dc:date>2022-12-12T21:36:04Z</dc:date>
    </item>
    <item>
      <title>Re: Is this code counting frequency in 12 months? Can someone explain how it works?</title>
      <link>https://communities.sas.com/t5/SAS-Enterprise-Guide/Is-this-code-counting-frequency-in-12-months-Can-someone-explain/m-p/849264#M41868</link>
      <description>&lt;P&gt;Please post the complete (all code, all messages) log of the PROC SQL by copy/pasting it into a window opened with this button:&lt;/P&gt;
&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="Bildschirmfoto 2020-04-07 um 08.32.59.jpg" style="width: 400px;"&gt;&lt;img src="https://communities.sas.com/t5/image/serverpage/image-id/54552i914D97BE1B0F21E5/image-size/medium?v=v2&amp;amp;px=400" role="button" title="Bildschirmfoto 2020-04-07 um 08.32.59.jpg" alt="Bildschirmfoto 2020-04-07 um 08.32.59.jpg" /&gt;&lt;/span&gt;&lt;/P&gt;</description>
      <pubDate>Mon, 12 Dec 2022 21:36:55 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Enterprise-Guide/Is-this-code-counting-frequency-in-12-months-Can-someone-explain/m-p/849264#M41868</guid>
      <dc:creator>Kurt_Bremser</dc:creator>
      <dc:date>2022-12-12T21:36:55Z</dc:date>
    </item>
  </channel>
</rss>

