<?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: the number of occurrences of the variable in a given year SAS in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/the-number-of-occurrences-of-the-variable-in-a-given-year-SAS/m-p/788480#M252112</link>
    <description>&lt;P&gt;No need for the format in this case for the missing values. The Tabulate table option MISSTEXT will suppress the . for the N statistic:&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;proc tabulate data = have out = want;
    class year category;
    keylabel n=' ';
    table year, category*N
       / misstext=' ';
run;&lt;/PRE&gt;
&lt;BLOCKQUOTE&gt;&lt;HR /&gt;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/12447"&gt;@Patrick&lt;/a&gt;&amp;nbsp;wrote:&lt;BR /&gt;
&lt;P&gt;Not sure if I understand but are you asking for something as simple as below?&lt;/P&gt;
&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="Patrick_0-1641385595933.png" style="width: 400px;"&gt;&lt;img src="https://communities.sas.com/t5/image/serverpage/image-id/67135i312A9CF2F8139CA5/image-size/medium?v=v2&amp;amp;px=400" role="button" title="Patrick_0-1641385595933.png" alt="Patrick_0-1641385595933.png" /&gt;&lt;/span&gt;&lt;/P&gt;
&lt;P&gt;If so then the main thing that's missing in your code is a comma in the table statement after variable year - used to separate the x from the y axis.&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data have;
  input id category $ year;
  cards;
1 X 2009
2 U 2009
3 X 2009
4 Y 2010
5 Y 2010
6 Z 2011
7 Z 2011
8 X 2012
9 U 2013
10 U 2013
;

proc format;
  value missasblank
    .=' '
    other=[best16.]
    ;
run;
proc tabulate data = have out = want;
    class year category;
    keylabel n=' ';
    table year, category*N*f=missasblank.;
run;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;HR /&gt;&lt;/BLOCKQUOTE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
    <pubDate>Wed, 05 Jan 2022 15:21:14 GMT</pubDate>
    <dc:creator>ballardw</dc:creator>
    <dc:date>2022-01-05T15:21:14Z</dc:date>
    <item>
      <title>the number of occurrences of the variable in a given year SAS</title>
      <link>https://communities.sas.com/t5/SAS-Programming/the-number-of-occurrences-of-the-variable-in-a-given-year-SAS/m-p/788430#M252085</link>
      <description>&lt;P&gt;Let's assume that i have data like this:&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;data have;&lt;BR /&gt;input id category $ year;&lt;BR /&gt;cards;&lt;BR /&gt;1 X 2009&lt;BR /&gt;2 U 2009&lt;BR /&gt;3 X 2009&lt;BR /&gt;4 Y 2010&lt;BR /&gt;5 Y 2010&lt;BR /&gt;6 Z 2011&lt;BR /&gt;7 Z 2011&lt;BR /&gt;8 X 2012&lt;BR /&gt;9 U 2013&lt;BR /&gt;10 U 2013&lt;BR /&gt;;&lt;BR /&gt;run;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Like in subject, I would like to establish the number of occurrences of the category in a given year.&lt;/P&gt;&lt;P&gt;I tried on my data to use proc tabulate:&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;proc tabulate data = have out = want;&lt;BR /&gt;&amp;nbsp; &amp;nbsp; class year category;&lt;BR /&gt;&amp;nbsp; &amp;nbsp; table year category*N;&lt;BR /&gt;run;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Ang got something like this:&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="newproblem.png" style="width: 400px;"&gt;&lt;img src="https://communities.sas.com/t5/image/serverpage/image-id/67133i515D5FEE38C3EB97/image-size/medium?v=v2&amp;amp;px=400" role="button" title="newproblem.png" alt="newproblem.png" /&gt;&lt;/span&gt;&lt;/P&gt;&lt;P&gt; Next i tried proc transpose:&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;proc transpose data=want out data=want;&lt;BR /&gt;&amp;nbsp; &amp;nbsp;by year;&lt;BR /&gt;&amp;nbsp; &amp;nbsp;id category;&lt;BR /&gt;&amp;nbsp; &amp;nbsp;var N;&lt;BR /&gt;run;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;But it didint help:&lt;/P&gt;&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="newproblem2.png" style="width: 400px;"&gt;&lt;img src="https://communities.sas.com/t5/image/serverpage/image-id/67134i7D69FBD76207AF55/image-size/medium?v=v2&amp;amp;px=400" role="button" title="newproblem2.png" alt="newproblem2.png" /&gt;&lt;/span&gt;&lt;/P&gt;&lt;P&gt; &lt;/P&gt;&lt;P&gt;What have I done wrong?&lt;/P&gt;</description>
      <pubDate>Wed, 05 Jan 2022 11:28:35 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/the-number-of-occurrences-of-the-variable-in-a-given-year-SAS/m-p/788430#M252085</guid>
      <dc:creator>moteku</dc:creator>
      <dc:date>2022-01-05T11:28:35Z</dc:date>
    </item>
    <item>
      <title />
      <link>https://communities.sas.com/t5/SAS-Programming/the-number-of-occurrences-of-the-variable-in-a-given-year-SAS/m-p/788432#M252087</link>
      <description />
      <pubDate>Wed, 05 Jan 2022 11:34:03 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/the-number-of-occurrences-of-the-variable-in-a-given-year-SAS/m-p/788432#M252087</guid>
      <dc:creator>moteku</dc:creator>
      <dc:date>2022-01-05T11:34:03Z</dc:date>
    </item>
    <item>
      <title>Re: the number of occurrences of the variable in a given year SAS</title>
      <link>https://communities.sas.com/t5/SAS-Programming/the-number-of-occurrences-of-the-variable-in-a-given-year-SAS/m-p/788433#M252088</link>
      <description>&lt;P&gt;Obviously, you didn't run this code, as data set HAVE is not created because of a coding error. Please provide us with correct working code, you will get faster help that way.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Nevertheless, I think this works. I have not tested it because your code to create data set HAVE doesn't work. In order for this to work, variable LAUNCHED must be numeric and a valid SAS data value — it can't be character.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;proc report data=have; 
    columns category launched;
    define category/group;
    define launched/across format=year.;
run;
&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Wed, 05 Jan 2022 11:24:20 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/the-number-of-occurrences-of-the-variable-in-a-given-year-SAS/m-p/788433#M252088</guid>
      <dc:creator>PaigeMiller</dc:creator>
      <dc:date>2022-01-05T11:24:20Z</dc:date>
    </item>
    <item>
      <title>Re: the number of occurrences of the variable in a given year SAS</title>
      <link>https://communities.sas.com/t5/SAS-Programming/the-number-of-occurrences-of-the-variable-in-a-given-year-SAS/m-p/788436#M252089</link>
      <description>I've corrected the question&lt;BR /&gt;</description>
      <pubDate>Wed, 05 Jan 2022 11:29:14 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/the-number-of-occurrences-of-the-variable-in-a-given-year-SAS/m-p/788436#M252089</guid>
      <dc:creator>moteku</dc:creator>
      <dc:date>2022-01-05T11:29:14Z</dc:date>
    </item>
    <item>
      <title>Re: the number of occurrences of the variable in a given year SAS</title>
      <link>https://communities.sas.com/t5/SAS-Programming/the-number-of-occurrences-of-the-variable-in-a-given-year-SAS/m-p/788438#M252091</link>
      <description>&lt;P&gt;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/13633"&gt;@StatDave&lt;/a&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Wed, 05 Jan 2022 11:51:13 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/the-number-of-occurrences-of-the-variable-in-a-given-year-SAS/m-p/788438#M252091</guid>
      <dc:creator>Ksharp</dc:creator>
      <dc:date>2022-01-05T11:51:13Z</dc:date>
    </item>
    <item>
      <title>Re: the number of occurrences of the variable in a given year SAS</title>
      <link>https://communities.sas.com/t5/SAS-Programming/the-number-of-occurrences-of-the-variable-in-a-given-year-SAS/m-p/788441#M252093</link>
      <description>&lt;P&gt;Not sure if I understand but are you asking for something as simple as below?&lt;/P&gt;
&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="Patrick_0-1641385595933.png" style="width: 400px;"&gt;&lt;img src="https://communities.sas.com/t5/image/serverpage/image-id/67135i312A9CF2F8139CA5/image-size/medium?v=v2&amp;amp;px=400" role="button" title="Patrick_0-1641385595933.png" alt="Patrick_0-1641385595933.png" /&gt;&lt;/span&gt;&lt;/P&gt;
&lt;P&gt;If so then the main thing that's missing in your code is a comma in the table statement after variable year - used to separate the x from the y axis.&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data have;
  input id category $ year;
  cards;
1 X 2009
2 U 2009
3 X 2009
4 Y 2010
5 Y 2010
6 Z 2011
7 Z 2011
8 X 2012
9 U 2013
10 U 2013
;

proc format;
  value missasblank
    .=' '
    other=[best16.]
    ;
run;
proc tabulate data = have out = want;
    class year category;
    keylabel n=' ';
    table year, category*N*f=missasblank.;
run;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Wed, 05 Jan 2022 12:28:40 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/the-number-of-occurrences-of-the-variable-in-a-given-year-SAS/m-p/788441#M252093</guid>
      <dc:creator>Patrick</dc:creator>
      <dc:date>2022-01-05T12:28:40Z</dc:date>
    </item>
    <item>
      <title>Re: the number of occurrences of the variable in a given year SAS</title>
      <link>https://communities.sas.com/t5/SAS-Programming/the-number-of-occurrences-of-the-variable-in-a-given-year-SAS/m-p/788449#M252097</link>
      <description>&lt;BLOCKQUOTE&gt;&lt;HR /&gt;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/404908"&gt;@moteku&lt;/a&gt;&amp;nbsp;wrote:&lt;BR /&gt;I've corrected the question&lt;BR /&gt;&lt;HR /&gt;&lt;/BLOCKQUOTE&gt;
&lt;P&gt;So the code I wrote should work on your corrected data if you remove &lt;FONT face="courier new,courier"&gt;FORMAT=YEAR.&lt;/FONT&gt;&lt;/P&gt;</description>
      <pubDate>Wed, 05 Jan 2022 12:43:17 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/the-number-of-occurrences-of-the-variable-in-a-given-year-SAS/m-p/788449#M252097</guid>
      <dc:creator>PaigeMiller</dc:creator>
      <dc:date>2022-01-05T12:43:17Z</dc:date>
    </item>
    <item>
      <title>Re: the number of occurrences of the variable in a given year SAS</title>
      <link>https://communities.sas.com/t5/SAS-Programming/the-number-of-occurrences-of-the-variable-in-a-given-year-SAS/m-p/788475#M252111</link>
      <description>Works excactly how I want, thanks really &lt;span class="lia-unicode-emoji" title=":red_heart:"&gt;❤️&lt;/span&gt;&lt;BR /&gt;</description>
      <pubDate>Wed, 05 Jan 2022 15:14:12 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/the-number-of-occurrences-of-the-variable-in-a-given-year-SAS/m-p/788475#M252111</guid>
      <dc:creator>moteku</dc:creator>
      <dc:date>2022-01-05T15:14:12Z</dc:date>
    </item>
    <item>
      <title>Re: the number of occurrences of the variable in a given year SAS</title>
      <link>https://communities.sas.com/t5/SAS-Programming/the-number-of-occurrences-of-the-variable-in-a-given-year-SAS/m-p/788480#M252112</link>
      <description>&lt;P&gt;No need for the format in this case for the missing values. The Tabulate table option MISSTEXT will suppress the . for the N statistic:&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;proc tabulate data = have out = want;
    class year category;
    keylabel n=' ';
    table year, category*N
       / misstext=' ';
run;&lt;/PRE&gt;
&lt;BLOCKQUOTE&gt;&lt;HR /&gt;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/12447"&gt;@Patrick&lt;/a&gt;&amp;nbsp;wrote:&lt;BR /&gt;
&lt;P&gt;Not sure if I understand but are you asking for something as simple as below?&lt;/P&gt;
&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="Patrick_0-1641385595933.png" style="width: 400px;"&gt;&lt;img src="https://communities.sas.com/t5/image/serverpage/image-id/67135i312A9CF2F8139CA5/image-size/medium?v=v2&amp;amp;px=400" role="button" title="Patrick_0-1641385595933.png" alt="Patrick_0-1641385595933.png" /&gt;&lt;/span&gt;&lt;/P&gt;
&lt;P&gt;If so then the main thing that's missing in your code is a comma in the table statement after variable year - used to separate the x from the y axis.&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data have;
  input id category $ year;
  cards;
1 X 2009
2 U 2009
3 X 2009
4 Y 2010
5 Y 2010
6 Z 2011
7 Z 2011
8 X 2012
9 U 2013
10 U 2013
;

proc format;
  value missasblank
    .=' '
    other=[best16.]
    ;
run;
proc tabulate data = have out = want;
    class year category;
    keylabel n=' ';
    table year, category*N*f=missasblank.;
run;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;HR /&gt;&lt;/BLOCKQUOTE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Wed, 05 Jan 2022 15:21:14 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/the-number-of-occurrences-of-the-variable-in-a-given-year-SAS/m-p/788480#M252112</guid>
      <dc:creator>ballardw</dc:creator>
      <dc:date>2022-01-05T15:21:14Z</dc:date>
    </item>
  </channel>
</rss>

