<?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(use of across) in SAS Procedures</title>
    <link>https://communities.sas.com/t5/SAS-Procedures/proc-report-use-of-across/m-p/61038#M17317</link>
    <description>In proc report when we define any variable as across,in that across variable can we have new computed variable as well.if yes how?  E.G&lt;BR /&gt;
&lt;BR /&gt;
proc report data = abcd;&lt;BR /&gt;
column empid type,(salary bonus percentage_bonus);&lt;BR /&gt;
define empid/display;&lt;BR /&gt;
define type/across;&lt;BR /&gt;
define salary/analysis;&lt;BR /&gt;
define bonus/analysis;&lt;BR /&gt;
define percentage_bonus/computed format percent10.2;&lt;BR /&gt;
compute percentage_bonus;&lt;BR /&gt;
percentage_bonus = ((salary-bonus)/salary) * 100;&lt;BR /&gt;
endcomp;&lt;BR /&gt;
quit;&lt;BR /&gt;
&lt;BR /&gt;
&lt;BR /&gt;
thanks</description>
    <pubDate>Sat, 01 Aug 2009 11:26:10 GMT</pubDate>
    <dc:creator>deleted_user</dc:creator>
    <dc:date>2009-08-01T11:26:10Z</dc:date>
    <item>
      <title>proc report(use of across)</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/proc-report-use-of-across/m-p/61038#M17317</link>
      <description>In proc report when we define any variable as across,in that across variable can we have new computed variable as well.if yes how?  E.G&lt;BR /&gt;
&lt;BR /&gt;
proc report data = abcd;&lt;BR /&gt;
column empid type,(salary bonus percentage_bonus);&lt;BR /&gt;
define empid/display;&lt;BR /&gt;
define type/across;&lt;BR /&gt;
define salary/analysis;&lt;BR /&gt;
define bonus/analysis;&lt;BR /&gt;
define percentage_bonus/computed format percent10.2;&lt;BR /&gt;
compute percentage_bonus;&lt;BR /&gt;
percentage_bonus = ((salary-bonus)/salary) * 100;&lt;BR /&gt;
endcomp;&lt;BR /&gt;
quit;&lt;BR /&gt;
&lt;BR /&gt;
&lt;BR /&gt;
thanks</description>
      <pubDate>Sat, 01 Aug 2009 11:26:10 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/proc-report-use-of-across/m-p/61038#M17317</guid>
      <dc:creator>deleted_user</dc:creator>
      <dc:date>2009-08-01T11:26:10Z</dc:date>
    </item>
    <item>
      <title>Re: proc report(use of across)</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/proc-report-use-of-across/m-p/61039#M17318</link>
      <description>Hi:&lt;BR /&gt;
  When you have a computed column under an ACROSS variable, you must use ABSOLUTE column names in your assignment &lt;BR /&gt;
statements. Consider this program:&lt;BR /&gt;
                  &lt;BR /&gt;
[pre]&lt;BR /&gt;
proc sort data=sashelp.shoes out=shoes;&lt;BR /&gt;
  by region subsidiary product;&lt;BR /&gt;
  where product in ('Slipper', 'Sandal') and&lt;BR /&gt;
        region in ('Asia', 'Pacific');&lt;BR /&gt;
run;&lt;BR /&gt;
                     &lt;BR /&gt;
ods html file='what_rep_does.html' style=sasweb;&lt;BR /&gt;
proc report data=shoes nowd out=lookatme;&lt;BR /&gt;
   title 'This Report Shows missing for PCTRET item';&lt;BR /&gt;
   column region subsidiary product,(sales returns pctret);&lt;BR /&gt;
   define region / display;&lt;BR /&gt;
   define subsidiary / display;&lt;BR /&gt;
   define product/across;&lt;BR /&gt;
   define sales / analysis f=comma8.;&lt;BR /&gt;
   define returns/ analysis f=comma8.;&lt;BR /&gt;
   define pctret / computed;&lt;BR /&gt;
   compute pctret;&lt;BR /&gt;
      pctret = .;&lt;BR /&gt;
   endcomp;&lt;BR /&gt;
run;&lt;BR /&gt;
                        &lt;BR /&gt;
proc print data=lookatme;&lt;BR /&gt;
  title 'This is how PROC REPORT internally names the columns';&lt;BR /&gt;
run;&lt;BR /&gt;
ods html close;&lt;BR /&gt;
[/pre]&lt;BR /&gt;
                                                                   &lt;BR /&gt;
If you ran the above code, the LISTING output from PROC REPORT (just for Asia) would look like this &lt;BR /&gt;
(with PCTRET missing):      &lt;BR /&gt;
                                            &lt;BR /&gt;
[pre]&lt;BR /&gt;
This Report Shows missing for PCTRET item&lt;BR /&gt;
                                                                                            &lt;BR /&gt;
                                                    Product&lt;BR /&gt;
                                     Sandal                         Slipper&lt;BR /&gt;
                             Total     Total                Total     Total&lt;BR /&gt;
  Region      Subsidiary     Sales   Returns     pctret     Sales   Returns     pctret&lt;BR /&gt;
  Asia        Bangkok        3,230       120          .         .         .          .&lt;BR /&gt;
  Asia        Bangkok            .         .          .     3,019       127          .&lt;BR /&gt;
  Asia        Seoul          4,978       105          .         .         .          .&lt;BR /&gt;
  Asia        Seoul              .         .          .   149,013     2,941          .&lt;BR /&gt;
                     [/pre]                                                                                &lt;BR /&gt;
                                                                                       &lt;BR /&gt;
and the PROC PRINT (just for Asia) would look like this:&lt;BR /&gt;
                                                                                &lt;BR /&gt;
[pre]&lt;BR /&gt;
This is how PROC REPORT internally names the columns&lt;BR /&gt;
                         &lt;BR /&gt;
Obs Region  Subsidiary           _C3_         _C4_ _C5_         _C6_         _C7_ _C8_ _BREAK_&lt;BR /&gt;
                     &lt;BR /&gt;
  1 Asia    Bangkok            $3,230         $120   .             .            .   .&lt;BR /&gt;
  2 Asia    Bangkok                 .            .   .        $3,019         $127   .&lt;BR /&gt;
  3 Asia    Seoul              $4,978         $105   .             .            .   .&lt;BR /&gt;
  4 Asia    Seoul                   .            .   .      $149,013       $2,941   .&lt;BR /&gt;
                                                                    &lt;BR /&gt;
[/pre]&lt;BR /&gt;
           &lt;BR /&gt;
                 &lt;BR /&gt;
Comparing the PROC PRINT and the PROC  REPORT, for just the first report row, we can see that _C3_ is the SALES value &lt;BR /&gt;
for Bangkok for sandals and that _c4_ is 120, which is the RETURNS value for Bangkok. Next _C5_ is for PCTRET (but is &lt;BR /&gt;
missing because of my assignment statement. OK, now we see that under each across variable, I have 3 variables nested. &lt;BR /&gt;
So _c3_, _c4_ and _c5_ belong to Sandal and _c6_, _c7_ and _c8_ belong to Slipper for every report row.&lt;BR /&gt;
                                                                                             &lt;BR /&gt;
                                           &lt;BR /&gt;
Now, because REGION and SUBSIDIARY had a usage of DISPLAY, I see 2 rows for Bangkok and 2 rows for Seoul. Probably not &lt;BR /&gt;
what I want. I'd like to collapse those down to just 1 row for Asia/Bangkok and 1 row for Asia/Seoul. This can be easily &lt;BR /&gt;
accomplished by changing the usage of REGION and SUBSIDIARY from DISPLAY to GROUP.&lt;BR /&gt;
                       &lt;BR /&gt;
Oh, wait, there's that pesky PCTRET that still needs a value. OK...Here's how we're going to use those absolute column &lt;BR /&gt;
names in our COMPUTE block:&lt;BR /&gt;
                                &lt;BR /&gt;
[pre]&lt;BR /&gt;
   compute pctret;&lt;BR /&gt;
      _c5_ = _c4_ / _c3_;&lt;BR /&gt;
      _c8_ = _c7_ / _c6_;&lt;BR /&gt;
   endcomp;&lt;BR /&gt;
                               &lt;BR /&gt;
[/pre]&lt;BR /&gt;
           &lt;BR /&gt;
     Being able to LOOK at the column names that report uses for ACROSS reports is a handy use of the OUT= option. You don't &lt;BR /&gt;
have to do it all the time, but when you're getting started with ACROSS, it's a good technique to use. Of course, if I &lt;BR /&gt;
had more PRODUCTs, there would be more "sets" of 3 going across the top of the report. &lt;BR /&gt;
                                                                                                     &lt;BR /&gt;
                                   &lt;BR /&gt;
After I make REGION and SUBSIDIARY GROUP items and change the compute block, this is what the rows for Asia now look like. &lt;BR /&gt;
You can see I also assigned formats, etc. The final program is at the end of the post.&lt;BR /&gt;
                                                                           &lt;BR /&gt;
[pre]&lt;BR /&gt;
This Report Uses ABSOLUTE column names/numbers&lt;BR /&gt;
&lt;BR /&gt;
                                                   Product&lt;BR /&gt;
                                     Sandal                       Slipper&lt;BR /&gt;
                             Total     Total               Total     Total&lt;BR /&gt;
  Region      Subsidiary     Sales   Returns    pctret     Sales   Returns    pctret&lt;BR /&gt;
  Asia        Bangkok        3,230       120    3.72%      3,019       127    4.21%&lt;BR /&gt;
              Seoul          4,978       105    2.11%    149,013     2,941    1.97%&lt;BR /&gt;
  Asia                       8,208       225    2.74%    152,032     3,068    2.02%&lt;BR /&gt;
[/pre]&lt;BR /&gt;
           &lt;BR /&gt;
                             &lt;BR /&gt;
I added a BREAK to get a summary line for Asia. With EMPID, you probably won't do that (but you probably will want &lt;BR /&gt;
EMPID to be a GROUP usage on the report).&lt;BR /&gt;
              &lt;BR /&gt;
There are a lot of good examples and explanations in this documentation which talks about using PROC REPORT in NOWD mode:&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;BR /&gt;
cynthia&lt;BR /&gt;
                     &lt;BR /&gt;
[pre]&lt;BR /&gt;
proc report data=shoes nowd;&lt;BR /&gt;
   title 'This Report Uses ABSOLUTE column names/numbers';&lt;BR /&gt;
   column region subsidiary product,(sales returns pctret);&lt;BR /&gt;
   define region / group f=$10.;&lt;BR /&gt;
   define subsidiary / group f=$10.;&lt;BR /&gt;
   define product/across;&lt;BR /&gt;
   define sales / analysis f=comma8.;&lt;BR /&gt;
   define returns/ analysis f=comma8.;&lt;BR /&gt;
   define pctret / computed f=percent8.2;&lt;BR /&gt;
   compute pctret;&lt;BR /&gt;
      _c5_ = _c4_ / _c3_;&lt;BR /&gt;
      _c8_ = _c7_ / _c6_;&lt;BR /&gt;
   endcomp;&lt;BR /&gt;
   break after region / summarize;&lt;BR /&gt;
   compute after region;&lt;BR /&gt;
      line ' ';&lt;BR /&gt;
   endcomp;&lt;BR /&gt;
run;&lt;BR /&gt;
[/pre]</description>
      <pubDate>Sat, 01 Aug 2009 16:13:44 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/proc-report-use-of-across/m-p/61039#M17318</guid>
      <dc:creator>Cynthia_sas</dc:creator>
      <dc:date>2009-08-01T16:13:44Z</dc:date>
    </item>
    <item>
      <title>Re: proc report(use of across)</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/proc-report-use-of-across/m-p/61040#M17319</link>
      <description>Thanks a lot Cynthia....Actually i am new to SAs so thats y i ma asking these type of questions..Its just been one month that i am using sas..Again thanks</description>
      <pubDate>Mon, 03 Aug 2009 11:40:25 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/proc-report-use-of-across/m-p/61040#M17319</guid>
      <dc:creator>deleted_user</dc:creator>
      <dc:date>2009-08-03T11:40:25Z</dc:date>
    </item>
  </channel>
</rss>

