<?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 freq to only get month and year from DATE9. in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/proc-freq-to-only-get-month-and-year-from-DATE9/m-p/637826#M189639</link>
    <description>&lt;P&gt;Change the format to MONYY.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Then run PROC FREQ&lt;/P&gt;</description>
    <pubDate>Mon, 06 Apr 2020 11:57:39 GMT</pubDate>
    <dc:creator>PaigeMiller</dc:creator>
    <dc:date>2020-04-06T11:57:39Z</dc:date>
    <item>
      <title>proc freq to only get month and year from DATE9.</title>
      <link>https://communities.sas.com/t5/SAS-Programming/proc-freq-to-only-get-month-and-year-from-DATE9/m-p/637824#M189637</link>
      <description>&lt;P&gt;Hi,&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Please can someone help me with code that will show the frequency of of my "APPLICATION" variable (which is a numeric, DATE9. variable), but in terms of only &lt;U&gt;month and year&lt;/U&gt;? For example, from my screenshot below (example extract of my dataset that contains 50,000 observations), a proc freq would output that there is &lt;U&gt;one account from FEB2018&lt;/U&gt;, t&lt;U&gt;hree accounts from JUL2019&lt;/U&gt; and &lt;U&gt;one account from JAN2020&lt;/U&gt;.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Would it be better to create a new variable (e.g. "APPLICATION_FINAL") that only keeps the month and year from "APPLICATION", then run a proc freq on the new variable (e.g. "APPLICATION_FINAL"). Or can a proc freq be done on "APPLICATION" &lt;U&gt;without&lt;/U&gt; overriding the data? Thanks!&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;proc freq data = cd.test;&lt;/P&gt;&lt;P&gt;&amp;nbsp; &amp;nbsp;table &lt;FONT color="#FF0000"&gt;.................&lt;/FONT&gt; ;&lt;/P&gt;&lt;P&gt;run;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-center" image-alt="DATE9 SAS.JPG" style="width: 231px;"&gt;&lt;img src="https://communities.sas.com/t5/image/serverpage/image-id/37954i68AF24F294C515BD/image-size/large?v=v2&amp;amp;px=999" role="button" title="DATE9 SAS.JPG" alt="DATE9 SAS.JPG" /&gt;&lt;/span&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Mon, 06 Apr 2020 11:59:38 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/proc-freq-to-only-get-month-and-year-from-DATE9/m-p/637824#M189637</guid>
      <dc:creator>Justin9</dc:creator>
      <dc:date>2020-04-06T11:59:38Z</dc:date>
    </item>
    <item>
      <title>Re: proc freq to only get month and year from DATE9.</title>
      <link>https://communities.sas.com/t5/SAS-Programming/proc-freq-to-only-get-month-and-year-from-DATE9/m-p/637825#M189638</link>
      <description>&lt;P&gt;Just use a proper format; proc freq, like other statistic procedures, will use the formatted value automatically:&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data have;
input date :yymmdd10.;
format date yymmd7.;
datalines;
2020-03-05
2020-03-08
2020-04-01
2020-05-07
;

proc freq data=have;
tables date;
run;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;DIV id="IDX" class="proc_title_group"&gt;
&lt;P class="c proctitle"&gt;Die Prozedur FREQ&lt;/P&gt;
&lt;/DIV&gt;
&lt;SECTION&gt;
&lt;ARTICLE aria-label="Einfache Häufigkeiten"&gt;
&lt;TABLE class="table" aria-label="Einfache Häufigkeiten"&gt;&lt;CAPTION aria-label="Einfache Häufigkeiten"&gt;&amp;nbsp;&lt;/CAPTION&gt;&lt;COLGROUP&gt;&lt;COL /&gt;&lt;/COLGROUP&gt;&lt;COLGROUP&gt;&lt;COL /&gt;&lt;COL /&gt;&lt;COL /&gt;&lt;COL /&gt;&lt;/COLGROUP&gt;
&lt;THEAD&gt;
&lt;TR&gt;
&lt;TH class="r b header" scope="col"&gt;date&lt;/TH&gt;
&lt;TH class="r b header" scope="col"&gt;Häufigkeit&lt;/TH&gt;
&lt;TH class="r b header" scope="col"&gt;Prozent&lt;/TH&gt;
&lt;TH class="r b header" scope="col"&gt;Kumuliert&lt;BR /&gt;Häufigkeit&lt;/TH&gt;
&lt;TH class="r b header" scope="col"&gt;Kumuliert&lt;BR /&gt;Prozent&lt;/TH&gt;
&lt;/TR&gt;
&lt;/THEAD&gt;
&lt;TBODY&gt;
&lt;TR&gt;
&lt;TH class="r rowheader" scope="row"&gt;2020-03&lt;/TH&gt;
&lt;TD class="r data"&gt;2&lt;/TD&gt;
&lt;TD class="r data"&gt;50.00&lt;/TD&gt;
&lt;TD class="r data"&gt;2&lt;/TD&gt;
&lt;TD class="r data"&gt;50.00&lt;/TD&gt;
&lt;/TR&gt;
&lt;TR&gt;
&lt;TH class="r rowheader" scope="row"&gt;2020-04&lt;/TH&gt;
&lt;TD class="r data"&gt;1&lt;/TD&gt;
&lt;TD class="r data"&gt;25.00&lt;/TD&gt;
&lt;TD class="r data"&gt;3&lt;/TD&gt;
&lt;TD class="r data"&gt;75.00&lt;/TD&gt;
&lt;/TR&gt;
&lt;TR&gt;
&lt;TH class="r rowheader" scope="row"&gt;2020-05&lt;/TH&gt;
&lt;TD class="r data"&gt;1&lt;/TD&gt;
&lt;TD class="r data"&gt;25.00&lt;/TD&gt;
&lt;TD class="r data"&gt;4&lt;/TD&gt;
&lt;TD class="r data"&gt;100.00&lt;/TD&gt;
&lt;/TR&gt;
&lt;/TBODY&gt;
&lt;/TABLE&gt;
&lt;/ARTICLE&gt;
&lt;/SECTION&gt;</description>
      <pubDate>Mon, 06 Apr 2020 11:56:39 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/proc-freq-to-only-get-month-and-year-from-DATE9/m-p/637825#M189638</guid>
      <dc:creator>Kurt_Bremser</dc:creator>
      <dc:date>2020-04-06T11:56:39Z</dc:date>
    </item>
    <item>
      <title>Re: proc freq to only get month and year from DATE9.</title>
      <link>https://communities.sas.com/t5/SAS-Programming/proc-freq-to-only-get-month-and-year-from-DATE9/m-p/637826#M189639</link>
      <description>&lt;P&gt;Change the format to MONYY.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Then run PROC FREQ&lt;/P&gt;</description>
      <pubDate>Mon, 06 Apr 2020 11:57:39 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/proc-freq-to-only-get-month-and-year-from-DATE9/m-p/637826#M189639</guid>
      <dc:creator>PaigeMiller</dc:creator>
      <dc:date>2020-04-06T11:57:39Z</dc:date>
    </item>
    <item>
      <title>Re: proc freq to only get month and year from DATE9.</title>
      <link>https://communities.sas.com/t5/SAS-Programming/proc-freq-to-only-get-month-and-year-from-DATE9/m-p/637828#M189641</link>
      <description>&lt;P&gt;Thanks, so in order to avoid overriding "APPLICATION", would I have to create a new variable e.g. "APPLICATION_FINAL" so that it's APPLICATION_FINAL=put(APPLICATION,monyy7.); , then run a proc freq on APPLICATION_FINAL?&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;A p&lt;SPAN&gt;roc freq&lt;/SPAN&gt; should then help me &lt;SPAN&gt;output (based on my extract screenshot) that there is&amp;nbsp;&lt;/SPAN&gt;&lt;U&gt;one account from FEB2018&lt;/U&gt;&lt;SPAN&gt;, t&lt;/SPAN&gt;&lt;U&gt;hree accounts from JUL2019&lt;/U&gt;&lt;SPAN&gt;&amp;nbsp;and&amp;nbsp;&lt;/SPAN&gt;&lt;U&gt;one account from JAN2020&lt;/U&gt;?&lt;/P&gt;</description>
      <pubDate>Mon, 06 Apr 2020 12:07:30 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/proc-freq-to-only-get-month-and-year-from-DATE9/m-p/637828#M189641</guid>
      <dc:creator>Justin9</dc:creator>
      <dc:date>2020-04-06T12:07:30Z</dc:date>
    </item>
    <item>
      <title>Re: proc freq to only get month and year from DATE9.</title>
      <link>https://communities.sas.com/t5/SAS-Programming/proc-freq-to-only-get-month-and-year-from-DATE9/m-p/637829#M189642</link>
      <description>&lt;BLOCKQUOTE&gt;&lt;HR /&gt;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/321018"&gt;@Justin9&lt;/a&gt;&amp;nbsp;wrote:&lt;BR /&gt;
&lt;P&gt;Thanks, so in order to avoid overriding "APPLICATION", would I have to create a new variable e.g. "APPLICATION_FINAL" so that it's APPLICATION_FINAL=put(APPLICATION,monyy7.); , then run a proc freq on APPLICATION_FINAL?&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;HR /&gt;&lt;/BLOCKQUOTE&gt;
&lt;P&gt;No, you simply need to apply a different format. There's no need for a new variable or overwriting data sets.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;proc freq data=cd.test;
     table application;
     format application monyy.;
run;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;Or, you could use PROC DATASETS to change the format without creating a new dataset and without creating a new variable, or you could apply the desired format at the time the data set is created.&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Mon, 06 Apr 2020 12:46:30 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/proc-freq-to-only-get-month-and-year-from-DATE9/m-p/637829#M189642</guid>
      <dc:creator>PaigeMiller</dc:creator>
      <dc:date>2020-04-06T12:46:30Z</dc:date>
    </item>
    <item>
      <title>Re: proc freq to only get month and year from DATE9.</title>
      <link>https://communities.sas.com/t5/SAS-Programming/proc-freq-to-only-get-month-and-year-from-DATE9/m-p/637839#M189646</link>
      <description>&lt;P&gt;Thanks a lot, it works! Just as a reference, do you mind telling me how this format would work when creating a proc sql table? Please can you edit my code below, where necessary?&lt;BR /&gt;&lt;BR /&gt;proc sql;&lt;BR /&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; create table test as&lt;/P&gt;&lt;P&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; select month&lt;BR /&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; , APPLICATION format=monyy.&lt;BR /&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; from cd.test&lt;BR /&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; group by month&lt;BR /&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;, APPLICATION ;&lt;BR /&gt;quit;&lt;/P&gt;</description>
      <pubDate>Mon, 06 Apr 2020 13:16:59 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/proc-freq-to-only-get-month-and-year-from-DATE9/m-p/637839#M189646</guid>
      <dc:creator>Justin9</dc:creator>
      <dc:date>2020-04-06T13:16:59Z</dc:date>
    </item>
    <item>
      <title>Re: proc freq to only get month and year from DATE9.</title>
      <link>https://communities.sas.com/t5/SAS-Programming/proc-freq-to-only-get-month-and-year-from-DATE9/m-p/637844#M189649</link>
      <description>&lt;P&gt;The SQL language is not SAS, it doesn't understand such concepts.&lt;/P&gt;
&lt;P&gt;So you will need to tell it EXACTLY what you want it to do.&amp;nbsp; To get something similar to what PROC FREQ would do you might do something like:&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;proc sql;
  create table test as
  select min(date) as date format=monyy7.
      , count(*) as count
  from have
  group by put(date,monyy7.)
  ;
quit;&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Mon, 06 Apr 2020 13:22:54 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/proc-freq-to-only-get-month-and-year-from-DATE9/m-p/637844#M189649</guid>
      <dc:creator>Tom</dc:creator>
      <dc:date>2020-04-06T13:22:54Z</dc:date>
    </item>
    <item>
      <title>Re: proc freq to only get month and year from DATE9.</title>
      <link>https://communities.sas.com/t5/SAS-Programming/proc-freq-to-only-get-month-and-year-from-DATE9/m-p/637845#M189650</link>
      <description>&lt;P&gt;Please use the "little running man" to post code, and work on your code formatting.&lt;/P&gt;
&lt;P&gt;In SQL, you need correct values in a column for group by to work properly:&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;proc sql;
create table test as
  select
    month,
    put(APPLICATION,yymmd7.) as application
  from cd.test
  group by month, calculated application
;
quit;&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Mon, 06 Apr 2020 13:23:33 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/proc-freq-to-only-get-month-and-year-from-DATE9/m-p/637845#M189650</guid>
      <dc:creator>Kurt_Bremser</dc:creator>
      <dc:date>2020-04-06T13:23:33Z</dc:date>
    </item>
  </channel>
</rss>

