<?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: Another Proc Report Question in SAS Procedures</title>
    <link>https://communities.sas.com/t5/SAS-Procedures/Another-Proc-Report-Question/m-p/76206#M22109</link>
    <description>Hi Cyntia. &lt;BR /&gt;
&lt;BR /&gt;
Thank you so much.  I had read countless documents on Proc Report and not one was as clear as your explanation.&lt;BR /&gt;
&lt;BR /&gt;
Once again you have saved me.&lt;BR /&gt;
&lt;BR /&gt;
Regards,&lt;BR /&gt;
Scott</description>
    <pubDate>Fri, 06 Mar 2009 05:51:20 GMT</pubDate>
    <dc:creator>Scottcom4</dc:creator>
    <dc:date>2009-03-06T05:51:20Z</dc:date>
    <item>
      <title>Another Proc Report Question</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/Another-Proc-Report-Question/m-p/76204#M22107</link>
      <description>Wow.  How much trouble am I having with these Proc Reports.&lt;BR /&gt;
&lt;BR /&gt;
I am hoping that someone can help me once again.&lt;BR /&gt;
&lt;BR /&gt;
The following code allows me to produce a report with all my coverage codes as variables, however the observations displayed are simply a count of how many times the each coveragecode appears in the dataset I am using.  What I wish to do is place my calculated frequency in these colums.  Is this possible?  If so, can someone help me with the syntax.&lt;BR /&gt;
&lt;BR /&gt;
Thank you very much.&lt;BR /&gt;
&lt;BR /&gt;
options nodate pageno=1 linesize=64&lt;BR /&gt;
        pagesize=60;&lt;BR /&gt;
proc report Data=Merged Out = Frequency headline headskip;&lt;BR /&gt;
   column exposmth coveragecode EarnedCov Claimcount Frequency;&lt;BR /&gt;
   define coveragecode / Across ;&lt;BR /&gt;
   define exposmth 	   / Group;&lt;BR /&gt;
   define EarnedCov    / Analysis Sum noprint;&lt;BR /&gt;
   define Claimcount   / Analysis Sum noprint ;&lt;BR /&gt;
   define Frequency    / Computed format = percent9.2;&lt;BR /&gt;
&lt;BR /&gt;
   compute Frequency;&lt;BR /&gt;
    	Frequency = Claimcount.sum / EarnedCov.sum;&lt;BR /&gt;
   endcomp;&lt;BR /&gt;
run;

Message was edited by: Scottcom4</description>
      <pubDate>Wed, 04 Mar 2009 06:15:51 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/Another-Proc-Report-Question/m-p/76204#M22107</guid>
      <dc:creator>Scottcom4</dc:creator>
      <dc:date>2009-03-04T06:15:51Z</dc:date>
    </item>
    <item>
      <title>Re: Another Proc Report Question</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/Another-Proc-Report-Question/m-p/76205#M22108</link>
      <description>Hi, Scott:&lt;BR /&gt;
  Wow, what a difference a comma and some parentheses can make in your program!&lt;BR /&gt;
&lt;BR /&gt;
  Basically, you will only get the COUNT or the N in an ACROSS scenario, unless you "cross" or "nest" your ACROSS variable with other report items or statistics. So, for example, if you wanted one item, it would be:&lt;BR /&gt;
[pre] column groupvar acrossvar,onevar; [/pre]&lt;BR /&gt;
&lt;BR /&gt;
if it was 2 items, it would be:&lt;BR /&gt;
[pre]     column groupvar acrossvar,(onevar twovar); [/pre]&lt;BR /&gt;
&lt;BR /&gt;
and if it was 2 items and a computed item, it might be:&lt;BR /&gt;
[pre] &lt;BR /&gt;
      column groupvar acrossvar,(onevar twovar calcvar); &lt;BR /&gt;
      define groupvar / group;&lt;BR /&gt;
      define acrossvar / across;&lt;BR /&gt;
      define onevar / sum;&lt;BR /&gt;
      define twovar / sum;&lt;BR /&gt;
      define calcvar / computed;&lt;BR /&gt;
[/pre]&lt;BR /&gt;
 &lt;BR /&gt;
And, now that you've learned about onevar.sum and twovar.sum in a COMPUTE block, you have to learn something else about ACROSS usage. Proc Report has yet -another- way to reference across variables. So, let's say that, in the above fake example, that acrossvar has 3 possible values: XXX, YYY and ZZZ. &lt;BR /&gt;
&lt;BR /&gt;
Essentially, you will have a report that looks like this:&lt;BR /&gt;
[pre]&lt;BR /&gt;
                    &lt;BR /&gt;
            ------------------------------ACROSSVAR------------------------------ &lt;BR /&gt;
            ---------XXX---------   ---------YYY---------   ---------ZZZ---------&lt;BR /&gt;
groupvar    onevar twovar calcvar   onevar twovar calcvar   onevar twovar calcvar&lt;BR /&gt;
AAA           111    222    333       110    220    330       100    200    300&lt;BR /&gt;
BBB            11     22     33        10     20     30        20     10     30&lt;BR /&gt;
[/pre]&lt;BR /&gt;
                                                                 &lt;BR /&gt;
Now Proc Report can get easily confused. If you plan to calculate CALCVAR by adding ONEVAR and TWOVAR -- how does Proc REPORT know that you want the ONEVAR and TWOVAR for XXX versus the ONEVAR and TWOVAR for YYY??? So, in this case, the simple ONEVAR.SUM and TWOVAR.SUM will not make PROC REPORT happy.&lt;BR /&gt;
&lt;BR /&gt;
Essentially, Proc Report goes through a setup phase when it gets started, and if you have any reference to ACROSS usage, then PROC REPORT figures out how many values you have for the across variables (in this case, 3), how many variables or items you have nested under the across variable (in this case, also 3) and how many items you have -before- the first ACROSS variable value (in this case -- 1 for groupvar). Then it assigns absolute column numbers to every one of the columns that comes from nesting within the ACROSS. Like this:&lt;BR /&gt;
[pre]&lt;BR /&gt;
                     &lt;BR /&gt;
            ------------------------------ACROSSVAR------------------------------ &lt;BR /&gt;
            ---------XXX---------   ---------YYY---------   ---------ZZZ---------&lt;BR /&gt;
groupvar    onevar twovar calcvar   onevar twovar calcvar   onevar twovar calcvar&lt;BR /&gt;
AAA           111    222    333       110    220    330       100    200    300&lt;BR /&gt;
BBB            11     22     33        10     20     30        20     10     30&lt;BR /&gt;
  |             |      |      |         |      |      |         |      |      |&lt;BR /&gt;
  v             v      v      v         v      v      v         v      v      v&lt;BR /&gt;
first col      _c2_   _c3_   _c4_      _c5_   _c6_   _c7_      _c8_   _c9_   _c10_&lt;BR /&gt;
              (these are now the "absolute" column names that REPORT wants you to use)&lt;BR /&gt;
[/pre]&lt;BR /&gt;
                 &lt;BR /&gt;
So, groupvar is conceptually column 1, but there's no confusion about how to reference it, so it counts as 1, but doesn't get an absolute name. However, starting with the column for ONEVAR under XXX, the column name internally becomes known as _c2_, and then TWOVAR under XXX becomes _c3_ and CALCVAR under XXX becomes _c4_, etc, etc. Even if you use NOPRINT to hide ONEVAR and TWOVAR, they still get absolute names assigned to them.&lt;BR /&gt;
 &lt;BR /&gt;
  That means your compute block would look like:&lt;BR /&gt;
[pre]&lt;BR /&gt;
compute calcvar;&lt;BR /&gt;
  _c4_ = _c2_ + _c3_;&lt;BR /&gt;
  _c7_ = _c5_ + _c6_;&lt;BR /&gt;
  _c10_ = _c8_ + _c9_;&lt;BR /&gt;
endcomp;&lt;BR /&gt;
[/pre]&lt;BR /&gt;
 &lt;BR /&gt;
There have been some previous forum postings on ACROSS usage with Proc Report and there are some good user group papers about PROC REPORT. These are only a few references:&lt;BR /&gt;
 &lt;A href="http://support.sas.com/rnd/papers/sgf07/sgf2007-report.pdf" target="_blank"&gt;http://support.sas.com/rnd/papers/sgf07/sgf2007-report.pdf&lt;/A&gt;&lt;BR /&gt;
&lt;A href="http://support.sas.com/documentation/onlinedoc/v82/techreport_p258.pdf" target="_blank"&gt;http://support.sas.com/documentation/onlinedoc/v82/techreport_p258.pdf&lt;/A&gt;&lt;BR /&gt;
&lt;A href="http://www2.sas.com/proceedings/sugi31/235-31.pdf" target="_blank"&gt;http://www2.sas.com/proceedings/sugi31/235-31.pdf&lt;/A&gt;&lt;BR /&gt;
&lt;A href="http://www2.sas.com/proceedings/sugi25/25/hands/25p148.pdf" target="_blank"&gt;http://www2.sas.com/proceedings/sugi25/25/hands/25p148.pdf&lt;/A&gt;&lt;BR /&gt;
           &lt;BR /&gt;
cynthia</description>
      <pubDate>Thu, 05 Mar 2009 00:26:05 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/Another-Proc-Report-Question/m-p/76205#M22108</guid>
      <dc:creator>Cynthia_sas</dc:creator>
      <dc:date>2009-03-05T00:26:05Z</dc:date>
    </item>
    <item>
      <title>Re: Another Proc Report Question</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/Another-Proc-Report-Question/m-p/76206#M22109</link>
      <description>Hi Cyntia. &lt;BR /&gt;
&lt;BR /&gt;
Thank you so much.  I had read countless documents on Proc Report and not one was as clear as your explanation.&lt;BR /&gt;
&lt;BR /&gt;
Once again you have saved me.&lt;BR /&gt;
&lt;BR /&gt;
Regards,&lt;BR /&gt;
Scott</description>
      <pubDate>Fri, 06 Mar 2009 05:51:20 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/Another-Proc-Report-Question/m-p/76206#M22109</guid>
      <dc:creator>Scottcom4</dc:creator>
      <dc:date>2009-03-06T05:51:20Z</dc:date>
    </item>
  </channel>
</rss>

