<?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 making use of a by variable in SAS Procedures</title>
    <link>https://communities.sas.com/t5/SAS-Procedures/proc-report-making-use-of-a-by-variable/m-p/73795#M21406</link>
    <description>I use the following column statement in proc report&lt;BR /&gt;
&lt;BR /&gt;
column varname&lt;BR /&gt;
(%do zz=1 %to &amp;amp;mcount; &amp;amp;&amp;amp;mname&amp;amp;zz %end;);;&lt;BR /&gt;
&lt;BR /&gt;
&amp;amp;&amp;amp;mname&amp;amp;zz contains the text for each month and year in the dataset&lt;BR /&gt;
&lt;BR /&gt;
I now want to break up the report by year so I've added a by year to the proc report.&lt;BR /&gt;
&lt;BR /&gt;
How can I test that the column name contains the correct year?  When I add the by statement I get lots of blank columns.  For example, march2009 is blank when the by value is 2008.</description>
    <pubDate>Wed, 30 Sep 2009 18:35:51 GMT</pubDate>
    <dc:creator>deleted_user</dc:creator>
    <dc:date>2009-09-30T18:35:51Z</dc:date>
    <item>
      <title>proc report making use of a by variable</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/proc-report-making-use-of-a-by-variable/m-p/73795#M21406</link>
      <description>I use the following column statement in proc report&lt;BR /&gt;
&lt;BR /&gt;
column varname&lt;BR /&gt;
(%do zz=1 %to &amp;amp;mcount; &amp;amp;&amp;amp;mname&amp;amp;zz %end;);;&lt;BR /&gt;
&lt;BR /&gt;
&amp;amp;&amp;amp;mname&amp;amp;zz contains the text for each month and year in the dataset&lt;BR /&gt;
&lt;BR /&gt;
I now want to break up the report by year so I've added a by year to the proc report.&lt;BR /&gt;
&lt;BR /&gt;
How can I test that the column name contains the correct year?  When I add the by statement I get lots of blank columns.  For example, march2009 is blank when the by value is 2008.</description>
      <pubDate>Wed, 30 Sep 2009 18:35:51 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/proc-report-making-use-of-a-by-variable/m-p/73795#M21406</guid>
      <dc:creator>deleted_user</dc:creator>
      <dc:date>2009-09-30T18:35:51Z</dc:date>
    </item>
    <item>
      <title>Re: proc report making use of a by variable</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/proc-report-making-use-of-a-by-variable/m-p/73796#M21407</link>
      <description>You can use the WHERE statement to control you rinput file selection with PROC REPORT.&lt;BR /&gt;
&lt;BR /&gt;
You will be better off sharing your SAS code, because it is unclear what SAS CHARACTER or NUMERIC variable(s) you have that are being used.&lt;BR /&gt;
&lt;BR /&gt;
For your own convenience, consider having a SAS DATE (NUMERIC type) variable in your input file (maybe you already have this?) and use it in your WHERE statement, such as:&lt;BR /&gt;
&lt;BR /&gt;
* select input observations only for current year;&lt;BR /&gt;
WHERE YEAR(&lt;DATEVAR&gt;) = YEAR(TODAY());&lt;BR /&gt;
&lt;BR /&gt;
The alternative if you only have a text-format month/year is to attempt to parse out the year-portion and use it in a WHERE statement.&lt;BR /&gt;
&lt;BR /&gt;
Some suggested reading on SAS DATE variables pasted below.&lt;BR /&gt;
&lt;BR /&gt;
&lt;BR /&gt;
Scott Barry&lt;BR /&gt;
SBBWorks, Inc.&lt;BR /&gt;
&lt;BR /&gt;
Step-by-Step Programming with Base SAS(R) Software&lt;BR /&gt;
Working with Dates in the SAS System&lt;BR /&gt;
&lt;A href="http://support.sas.com/documentation/cdl/en/basess/58133/HTML/default/a001304321.htm" target="_blank"&gt;http://support.sas.com/documentation/cdl/en/basess/58133/HTML/default/a001304321.htm&lt;/A&gt;&lt;/DATEVAR&gt;</description>
      <pubDate>Wed, 30 Sep 2009 20:13:05 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/proc-report-making-use-of-a-by-variable/m-p/73796#M21407</guid>
      <dc:creator>sbb</dc:creator>
      <dc:date>2009-09-30T20:13:05Z</dc:date>
    </item>
    <item>
      <title>Re: proc report making use of a by variable</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/proc-report-making-use-of-a-by-variable/m-p/73797#M21408</link>
      <description>Have you tried reorganising your data to use &lt;BR /&gt;
[pre]define month /across[/pre] &lt;BR /&gt;
so that the values of&lt;BR /&gt;
[pre]column &amp;amp;&amp;amp;mname&amp;amp;zz [/pre]&lt;BR /&gt;
now come from one variable ?&lt;BR /&gt;
&lt;BR /&gt;
There is no girl aged 16, and the column 16 does not appear for girls in:&lt;BR /&gt;
[pre]&lt;BR /&gt;
proc sort data=SASHELP.CLASS out=CLASS;&lt;BR /&gt;
  by SEX;&lt;BR /&gt;
proc report data=CLASS nowd;&lt;BR /&gt;
  define AGE /across;&lt;BR /&gt;
  define WEIGHT /mean;&lt;BR /&gt;
  column AGE,WEIGHT;&lt;BR /&gt;
  by SEX;&lt;BR /&gt;
  run;&lt;BR /&gt;
quit;&lt;BR /&gt;
[/pre]&lt;BR /&gt;
If you force the column name in the column statement, then that column will be shown.</description>
      <pubDate>Thu, 01 Oct 2009 22:08:05 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/proc-report-making-use-of-a-by-variable/m-p/73797#M21408</guid>
      <dc:creator>ChrisNZ</dc:creator>
      <dc:date>2009-10-01T22:08:05Z</dc:date>
    </item>
    <item>
      <title>Re: proc report making use of a by variable</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/proc-report-making-use-of-a-by-variable/m-p/73798#M21409</link>
      <description>To get it to work I had to create a macro variable&lt;BR /&gt;
&lt;BR /&gt;
call symput('mmm' || left(cnt), '_C'||compress(monthnum+1)||'_'); &lt;BR /&gt;
&lt;BR /&gt;
where monthnum is the number 1 through 12 of each month.  To this I had to add one so in the compute I could refer to the column number</description>
      <pubDate>Mon, 05 Oct 2009 17:59:39 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/proc-report-making-use-of-a-by-variable/m-p/73798#M21409</guid>
      <dc:creator>deleted_user</dc:creator>
      <dc:date>2009-10-05T17:59:39Z</dc:date>
    </item>
  </channel>
</rss>

