<?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 report across usage in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/proc-report-across-usage/m-p/811141#M319940</link>
    <description>&lt;P&gt;Hi Cynthia,&lt;/P&gt;
&lt;P&gt;Appreciate your guidance.&lt;/P&gt;
&lt;P&gt;I see the compute block needs to be different from what I have for pctutd for the ACROSS usage.&lt;/P&gt;
&lt;P&gt;I tried using the following (not sure which column SAS sees utd as since I don't have it listed in the column statement&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;compute pctutd;&lt;BR /&gt;pctutd=c5.sum/c4.sum;&lt;BR /&gt;endcompute;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;and I'm now I"m getting the following error message:&lt;/P&gt;
&lt;P&gt;&lt;BR /&gt;ERROR: The variable type of C5.SUM is invalid in this context.&lt;BR /&gt;ERROR: The variable type of C4.SUM is invalid in this context.&lt;/P&gt;</description>
    <pubDate>Mon, 02 May 2022 21:58:10 GMT</pubDate>
    <dc:creator>jcis7</dc:creator>
    <dc:date>2022-05-02T21:58:10Z</dc:date>
    <item>
      <title>proc report across usage</title>
      <link>https://communities.sas.com/t5/SAS-Programming/proc-report-across-usage/m-p/810746#M319741</link>
      <description>&lt;P&gt;G'day,&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;I have the following program:&amp;nbsp; Part 1 &amp;amp; 2 runs without SAS errors except Part 3 doesn't run. I'm trying to add pctud so that is shows under type (i.e, ask SAS to&amp;nbsp; calculate pctutd&amp;nbsp; across the two different types) and also ask SAS to calculate it for the combined types (which is equivalent to pctutd in Part 2) so it will have 3 columns with pctutd: the first column (after locale, year, grade, and children)&amp;nbsp; with pctutd that sums utd for all types (type=class &amp;amp; nonclass) and divides it by the totalchildren for all types, the 2nd column that sums utd for observations with type=class and divides it by totalchildren for type=class&amp;nbsp; &amp;nbsp;and the 3rd column with pctutd for nonclass, all grouped by locale and year. Any help you can give will be greatly appreciated.&amp;nbsp; And it will have a last column that has the % of entities that have nonclass type:&amp;nbsp; so sas counts and sums the number of entities that have nonclass type for example in locale North and divides it by the total of entities in locale North, etc... Thank you.&lt;/P&gt;
&lt;PRE&gt;*Part 1--dataset;
data have;
   input locale $ year $ grade $ totalchildren  utd  type $;
   datalines;
North 2020 5th 120 119 class 
South 2020 5th 140 120 nonclass
East 2020 5th 18 10	nonclass
West 2020 5th 9 9 class
North 2020 5th 11 9 class


;


*Part 2--program that has no errors except it doesn't give output I want;

proc report data = have out=want nowd missing completerows ; 
column locale year grade totalchildren utd pctutd type; 

	define locale / group 'Locale'; 
	define year / group; define grade / group; 
	define totalchildren / analysis sum; 
	define utd / analysis noprint; 
	define pctutd / computed; 
		compute pctutd; 
		pctutd=utd.sum/totalchildren.sum; 
		endcompute;  
   define type / across 'Type'; 

   *--summarizes ALL; 
   rbreak before /summarize;    
   compute before; 
   locale= 'ALL'; 
   year="current"; 
   grade="5th"; 
   endcomp; 

run;&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;/PRE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;Current output&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;DIV class="branch"&gt;
&lt;DIV align="center"&gt;
&lt;TABLE class="table" summary="Procedure Report: Detailed and/or summarized report" frame="box" rules="all" cellspacing="0" cellpadding="5"&gt;
&lt;THEAD&gt;
&lt;TR&gt;
&lt;TH class="c header" colspan="5" scope="colgroup"&gt;&amp;nbsp;&lt;/TH&gt;
&lt;TH class="c header" colspan="2" scope="colgroup"&gt;Type&lt;/TH&gt;
&lt;/TR&gt;
&lt;TR&gt;
&lt;TH class="c header" scope="col"&gt;Locale&lt;/TH&gt;
&lt;TH class="c header" scope="col"&gt;year&lt;/TH&gt;
&lt;TH class="c header" scope="col"&gt;grade&lt;/TH&gt;
&lt;TH class="c header" scope="col"&gt;totalchildren&lt;/TH&gt;
&lt;TH class="c header" scope="col"&gt;pctutd&lt;/TH&gt;
&lt;TH class="c header" scope="col"&gt;class&lt;/TH&gt;
&lt;TH class="c header" scope="col"&gt;nonclass&lt;/TH&gt;
&lt;/TR&gt;
&lt;/THEAD&gt;
&lt;TBODY&gt;
&lt;TR&gt;
&lt;TD class="l dataemphasis"&gt;ALL&lt;/TD&gt;
&lt;TD class="l dataemphasis"&gt;current&lt;/TD&gt;
&lt;TD class="l dataemphasis"&gt;5th&lt;/TD&gt;
&lt;TD class="r dataemphasis"&gt;298&lt;/TD&gt;
&lt;TD class="r dataemphasis"&gt;0.8959732&lt;/TD&gt;
&lt;TD class="r dataemphasis"&gt;3&lt;/TD&gt;
&lt;TD class="r dataemphasis"&gt;2&lt;/TD&gt;
&lt;/TR&gt;
&lt;TR&gt;
&lt;TD class="l data"&gt;East&lt;/TD&gt;
&lt;TD class="l data"&gt;2020&lt;/TD&gt;
&lt;TD class="l data"&gt;5th&lt;/TD&gt;
&lt;TD class="r data"&gt;18&lt;/TD&gt;
&lt;TD class="r data"&gt;0.5555556&lt;/TD&gt;
&lt;TD class="r data"&gt;0&lt;/TD&gt;
&lt;TD class="r data"&gt;1&lt;/TD&gt;
&lt;/TR&gt;
&lt;TR&gt;
&lt;TD class="l data"&gt;North&lt;/TD&gt;
&lt;TD class="l data"&gt;2020&lt;/TD&gt;
&lt;TD class="l data"&gt;5th&lt;/TD&gt;
&lt;TD class="r data"&gt;131&lt;/TD&gt;
&lt;TD class="r data"&gt;0.9770992&lt;/TD&gt;
&lt;TD class="r data"&gt;2&lt;/TD&gt;
&lt;TD class="r data"&gt;0&lt;/TD&gt;
&lt;/TR&gt;
&lt;TR&gt;
&lt;TD class="l data"&gt;South&lt;/TD&gt;
&lt;TD class="l data"&gt;2020&lt;/TD&gt;
&lt;TD class="l data"&gt;5th&lt;/TD&gt;
&lt;TD class="r data"&gt;140&lt;/TD&gt;
&lt;TD class="r data"&gt;0.8571429&lt;/TD&gt;
&lt;TD class="r data"&gt;0&lt;/TD&gt;
&lt;TD class="r data"&gt;1&lt;/TD&gt;
&lt;/TR&gt;
&lt;TR&gt;
&lt;TD class="l data"&gt;West&lt;/TD&gt;
&lt;TD class="l data"&gt;2020&lt;/TD&gt;
&lt;TD class="l data"&gt;5th&lt;/TD&gt;
&lt;TD class="r data"&gt;9&lt;/TD&gt;
&lt;TD class="r data"&gt;1&lt;/TD&gt;
&lt;TD class="r data"&gt;1&lt;/TD&gt;
&lt;TD class="r data"&gt;0&lt;/TD&gt;
&lt;/TR&gt;
&lt;/TBODY&gt;
&lt;/TABLE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;
*--part 3 - nonworking program
proc report data = have out=want nowd missing completerows ; 
column locale year grade totalchildren type,pctutd&lt;BR /&gt;('Overall' type pctutd);

	define locale / group 'Locale'; 
	define year / group; define grade / group; 
	define totalchildren / analysis sum; 
	define utd / analysis noprint;  
	define pctutd / computed; 
		compute pctutd; 
		pctutd=utd.sum/totalchildren.sum; 
		endcompute;  
   define type / across 'Type'; 

   *--summarizes ALL; 
   rbreak before /summarize;    
   compute before; 
   locale= 'ALL'; 
   year="current"; 
   grade="5th"; 
   endcomp; 

run;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;/DIV&gt;
&lt;/DIV&gt;</description>
      <pubDate>Fri, 29 Apr 2022 21:04:36 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/proc-report-across-usage/m-p/810746#M319741</guid>
      <dc:creator>jcis7</dc:creator>
      <dc:date>2022-04-29T21:04:36Z</dc:date>
    </item>
    <item>
      <title>Re: proc report across usage</title>
      <link>https://communities.sas.com/t5/SAS-Programming/proc-report-across-usage/m-p/810760#M319744</link>
      <description>&lt;P&gt;Hi: Take a look at this paper: &lt;A href="https://support.sas.com/resources/papers/proceedings14/SAS388-2014.pdf" target="_blank"&gt;https://support.sas.com/resources/papers/proceedings14/SAS388-2014.pdf&lt;/A&gt; starting on page 7. You need use absolute column numbers when you want to compute a value that's UNDER an ACROSS item.&lt;/P&gt;
&lt;P&gt;Cynthia&lt;/P&gt;</description>
      <pubDate>Fri, 29 Apr 2022 22:31:42 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/proc-report-across-usage/m-p/810760#M319744</guid>
      <dc:creator>Cynthia_sas</dc:creator>
      <dc:date>2022-04-29T22:31:42Z</dc:date>
    </item>
    <item>
      <title>Re: proc report across usage</title>
      <link>https://communities.sas.com/t5/SAS-Programming/proc-report-across-usage/m-p/811141#M319940</link>
      <description>&lt;P&gt;Hi Cynthia,&lt;/P&gt;
&lt;P&gt;Appreciate your guidance.&lt;/P&gt;
&lt;P&gt;I see the compute block needs to be different from what I have for pctutd for the ACROSS usage.&lt;/P&gt;
&lt;P&gt;I tried using the following (not sure which column SAS sees utd as since I don't have it listed in the column statement&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;compute pctutd;&lt;BR /&gt;pctutd=c5.sum/c4.sum;&lt;BR /&gt;endcompute;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;and I'm now I"m getting the following error message:&lt;/P&gt;
&lt;P&gt;&lt;BR /&gt;ERROR: The variable type of C5.SUM is invalid in this context.&lt;BR /&gt;ERROR: The variable type of C4.SUM is invalid in this context.&lt;/P&gt;</description>
      <pubDate>Mon, 02 May 2022 21:58:10 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/proc-report-across-usage/m-p/811141#M319940</guid>
      <dc:creator>jcis7</dc:creator>
      <dc:date>2022-05-02T21:58:10Z</dc:date>
    </item>
    <item>
      <title>Re: proc report across usage</title>
      <link>https://communities.sas.com/t5/SAS-Programming/proc-report-across-usage/m-p/811150#M319944</link>
      <description>Hi:&lt;BR /&gt;  When I use the absolute column reference it is ALWAYS _C2_, _C3_, _C4_, etc...you need those underscores. And, the good news is that because it is the ABSOLUTE column number, you don't need the .sum as you would with a "regular" numeric item. So you should be able to simplify your formula to something like:&lt;BR /&gt;PCTUTD = _C5_ / _C4_;&lt;BR /&gt;&lt;BR /&gt;  Without data it's hard to guess. I thought I showed using OUT= in the paper to be able to understand which column numbers belonged to which column so you could get the numbers right. But, also remember, if PCTUTD is UNDER TYPE, then if you have 2 types, you'll also get absolute column numbers for two values for PCTUTD under each TYPE as well. Something like this -- these columns are totally made up, because I don't quite understand your COLUMN statement without data to run through the program to double check. &lt;BR /&gt;_C6_ = _C5_ / _C4_;&lt;BR /&gt;_C8_ = _C7_/_C4_;&lt;BR /&gt;&lt;BR /&gt;  I see that you're using UTD in Part 2 and I see UTD in a DEFINE in Part 3, but why isn't UTD on the COLUMN statement in Part 3?  You'll probably get an error without UTD in the COLUMN statement and if you use PCTUTD under TYPE and not under TYPE, then you'll have a problem too with the COMPUTE block. Also, when you calculate PCTUTD under each value of TYPE, don't you also need the TOTALCHILDREN value for each TYPE so the division works out. I can't figure out from your posted data example, what the right numbers should be. Can you mock up something with the actual numbers that you expect to get based on the data you posted? Because otherwise, it's very hard to understand what is getting divided by what to produce PCTUTD. &lt;BR /&gt;&lt;BR /&gt;  Also, I'd recommend ditching the final COMPUTE block for ALL right now and concentrate on getting the overall column header structure and numbers right every place else and then do the COMPUTE block for ALL because you don't want to fiddle with it while you're getting everything else just right.&lt;BR /&gt;Cynthia</description>
      <pubDate>Tue, 03 May 2022 00:53:35 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/proc-report-across-usage/m-p/811150#M319944</guid>
      <dc:creator>Cynthia_sas</dc:creator>
      <dc:date>2022-05-03T00:53:35Z</dc:date>
    </item>
  </channel>
</rss>

