<?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: Edit values in columns in proc report in ODS and Base Reporting</title>
    <link>https://communities.sas.com/t5/ODS-and-Base-Reporting/Edit-values-in-columns-in-proc-report/m-p/71280#M8180</link>
    <description>Hi &lt;BR /&gt;
&lt;BR /&gt;
Thanks for your reply. I still have som issues about this. How do I refer to the column mean and  n i this case? I want to clear mean if n is less than 5:&lt;BR /&gt;
&lt;BR /&gt;
I also want to change the labels for mean and n, is that possible when you uses absolute column names with statistics? &lt;BR /&gt;
&lt;BR /&gt;
proc report data = test nowd;&lt;BR /&gt;
column sex category,  salary, (mean n) ;&lt;BR /&gt;
define sex / group "Sex" ;&lt;BR /&gt;
define category / across "" across;&lt;BR /&gt;
&lt;BR /&gt;
define salary / analysis  ;&lt;BR /&gt;
compute mean;&lt;BR /&gt;
  if n lt 5 then mean = 0;&lt;BR /&gt;
endcomp;&lt;BR /&gt;
run;&lt;BR /&gt;
ods html close; &lt;BR /&gt;
&lt;BR /&gt;
Thanks in advance&lt;BR /&gt;
Jenny</description>
    <pubDate>Tue, 22 Sep 2009 09:48:04 GMT</pubDate>
    <dc:creator>Jennys</dc:creator>
    <dc:date>2009-09-22T09:48:04Z</dc:date>
    <item>
      <title>Edit values in columns in proc report</title>
      <link>https://communities.sas.com/t5/ODS-and-Base-Reporting/Edit-values-in-columns-in-proc-report/m-p/71278#M8178</link>
      <description>Hi&lt;BR /&gt;
&lt;BR /&gt;
I have a proc report where I need to null some values based on a condition. It works fine when i have a "simple" proc report, but when I make a crosstable I have problems. &lt;BR /&gt;
I have made an example of the two reports below:&lt;BR /&gt;
&lt;BR /&gt;
In the first table the mean for sex=1 is set to 0, since there are fewer than 7 players. &lt;BR /&gt;
&lt;BR /&gt;
I want the same for the second table, ie the only mean that should show is the mean for sex=2 and category=2. Since the number of categorys in the input table varies, I can´t use the _cx_ to fix this. &lt;BR /&gt;
&lt;BR /&gt;
&lt;BR /&gt;
Any suggestions? &lt;BR /&gt;
&lt;BR /&gt;
Tks in advance&lt;BR /&gt;
Jenny&lt;BR /&gt;
&lt;BR /&gt;
&lt;BR /&gt;
&lt;BR /&gt;
&lt;BR /&gt;
data test;&lt;BR /&gt;
input sex category salary;&lt;BR /&gt;
cards;&lt;BR /&gt;
1 2 11000&lt;BR /&gt;
1 2 10000&lt;BR /&gt;
1 3 15000&lt;BR /&gt;
1 3 16000&lt;BR /&gt;
1 2 14500&lt;BR /&gt;
1 2 13000&lt;BR /&gt;
2 2 10000&lt;BR /&gt;
2 3 10000&lt;BR /&gt;
2 2 12000&lt;BR /&gt;
2 2 13000&lt;BR /&gt;
2 2 15000&lt;BR /&gt;
2 2 17000&lt;BR /&gt;
2 2 15000&lt;BR /&gt;
2 2 17000&lt;BR /&gt;
&lt;BR /&gt;
;&lt;BR /&gt;
run;&lt;BR /&gt;
&lt;BR /&gt;
ods listing close;&lt;BR /&gt;
ods html body = 'test.html' style=seaside;&lt;BR /&gt;
title 'This report works fine , with the mean nulled for less than 7 players';&lt;BR /&gt;
proc report data = test nowd;&lt;BR /&gt;
  column  sex   salary=lant salary=lmean;&lt;BR /&gt;
  define sex  / group "Sex" ;&lt;BR /&gt;
define lant / n format = nlnum8. 'Players' ;&lt;BR /&gt;
define lmean / mean format = nlnum8. 'Mean'   style={just=r} ;&lt;BR /&gt;
compute lmean;&lt;BR /&gt;
  if lant lt 7 then lmean = 0;&lt;BR /&gt;
endcomp;&lt;BR /&gt;
&lt;BR /&gt;
run;&lt;BR /&gt;
title 'The columns for mean doesn´t get nulled';&lt;BR /&gt;
proc report data = test out = tt nowd;&lt;BR /&gt;
  column  sex category , ( salary=lant salary=lmean ) ;&lt;BR /&gt;
  define sex  / group "Sex" ;&lt;BR /&gt;
  define category / across  "" across;&lt;BR /&gt;
define lant / n format = nlnum8. 'Players' ;&lt;BR /&gt;
define lmean / mean format = nlnum8. 'Mean'   style={just=r} ;&lt;BR /&gt;
&lt;BR /&gt;
compute lmean;&lt;BR /&gt;
  if lant lt 7 then lmean = 0;&lt;BR /&gt;
endcomp;&lt;BR /&gt;
&lt;BR /&gt;
run;&lt;BR /&gt;
ods html close;</description>
      <pubDate>Mon, 14 Sep 2009 20:28:17 GMT</pubDate>
      <guid>https://communities.sas.com/t5/ODS-and-Base-Reporting/Edit-values-in-columns-in-proc-report/m-p/71278#M8178</guid>
      <dc:creator>Jennys</dc:creator>
      <dc:date>2009-09-14T20:28:17Z</dc:date>
    </item>
    <item>
      <title>Re: Edit values in columns in proc report</title>
      <link>https://communities.sas.com/t5/ODS-and-Base-Reporting/Edit-values-in-columns-in-proc-report/m-p/71279#M8179</link>
      <description>Hi, &lt;BR /&gt;
When you use PROC REPORT and an ACROSS usage to do cross-tabular reports, you need to use ABSOLUTE column names in your compute block.&lt;BR /&gt;
 &lt;BR /&gt;
Look at this previous forum posting for an explanation and some recommendations of how to do the coding and some recommendations of reading material on the subject.&lt;BR /&gt;
&lt;A href="http://support.sas.com/forums/thread.jspa?messageID=23870崾" target="_blank"&gt;http://support.sas.com/forums/thread.jspa?messageID=23870崾&lt;/A&gt;&lt;BR /&gt;
 &lt;BR /&gt;
cynthia</description>
      <pubDate>Tue, 15 Sep 2009 01:30:20 GMT</pubDate>
      <guid>https://communities.sas.com/t5/ODS-and-Base-Reporting/Edit-values-in-columns-in-proc-report/m-p/71279#M8179</guid>
      <dc:creator>Cynthia_sas</dc:creator>
      <dc:date>2009-09-15T01:30:20Z</dc:date>
    </item>
    <item>
      <title>Re: Edit values in columns in proc report</title>
      <link>https://communities.sas.com/t5/ODS-and-Base-Reporting/Edit-values-in-columns-in-proc-report/m-p/71280#M8180</link>
      <description>Hi &lt;BR /&gt;
&lt;BR /&gt;
Thanks for your reply. I still have som issues about this. How do I refer to the column mean and  n i this case? I want to clear mean if n is less than 5:&lt;BR /&gt;
&lt;BR /&gt;
I also want to change the labels for mean and n, is that possible when you uses absolute column names with statistics? &lt;BR /&gt;
&lt;BR /&gt;
proc report data = test nowd;&lt;BR /&gt;
column sex category,  salary, (mean n) ;&lt;BR /&gt;
define sex / group "Sex" ;&lt;BR /&gt;
define category / across "" across;&lt;BR /&gt;
&lt;BR /&gt;
define salary / analysis  ;&lt;BR /&gt;
compute mean;&lt;BR /&gt;
  if n lt 5 then mean = 0;&lt;BR /&gt;
endcomp;&lt;BR /&gt;
run;&lt;BR /&gt;
ods html close; &lt;BR /&gt;
&lt;BR /&gt;
Thanks in advance&lt;BR /&gt;
Jenny</description>
      <pubDate>Tue, 22 Sep 2009 09:48:04 GMT</pubDate>
      <guid>https://communities.sas.com/t5/ODS-and-Base-Reporting/Edit-values-in-columns-in-proc-report/m-p/71280#M8180</guid>
      <dc:creator>Jennys</dc:creator>
      <dc:date>2009-09-22T09:48:04Z</dc:date>
    </item>
    <item>
      <title>Re: Edit values in columns in proc report</title>
      <link>https://communities.sas.com/t5/ODS-and-Base-Reporting/Edit-values-in-columns-in-proc-report/m-p/71281#M8181</link>
      <description>Hi:&lt;BR /&gt;
  I'm not sure what you mean by changing the headers? You can use N and MEAN in DEFINE statements:&lt;BR /&gt;
[pre]&lt;BR /&gt;
  define n / "Count of Players";&lt;BR /&gt;
  define mean / "Adjusted Mean";&lt;BR /&gt;
[/pre]&lt;BR /&gt;
                                              &lt;BR /&gt;
This gives you the opportunity to change the column headers.&lt;BR /&gt;
&lt;BR /&gt;
One useful technique for determining what absolute column names have been assigned to your ACROSS variables, is to use the OUT= option to take a look:&lt;BR /&gt;
[pre]&lt;BR /&gt;
  proc report data=test nowd out=whatcols;&lt;BR /&gt;
[/pre]&lt;BR /&gt;
 &lt;BR /&gt;
Then, a PROC PRINT after this step will reveal how the columns are named. In your case, if you had 2 possible values for category and you have N and MEAN nested underneath each category, then PROC REPORT would name 4 columns. Since SEX is the first column, the numbering would start at _c2_ and _c3_ for N and MEAN under the first category and _c4_ and _c5_ for N and MEAN under the second category.&lt;BR /&gt;
 &lt;BR /&gt;
You may wonder why I listed N first, that's because PROC REPORT builds a report row from Left to Right. If you want to conditionally alter the value for MEAN for every category, based on N, then N has to appear BEFORE MEAN in the COLUMN statement:&lt;BR /&gt;
[pre]&lt;BR /&gt;
  column sex category, salary, (n mean);&lt;BR /&gt;
[/pre]&lt;BR /&gt;
             &lt;BR /&gt;
If you want to test N when MEAN is being written on the report row (so you can change the MEAN), then N has to be placed on the report row BEFORE MEAN, so it is available for the test. PROC REPORT does not have a Program Data Vector (like the DATA step) -- so when N is being placed on the report, there is no visibility of MEAN.&lt;BR /&gt;
    &lt;BR /&gt;
So, finally, how you would change MEAN is in a COMPUTE block. You were on the right track -- but only for a report without an ACROSS variable. But the simple column name "MEAN" -- while it is OK for the COMPUTE block-- is not OK for the IF statement. You need to tell PROC REPORT exactly WHICH value of MEAN should be adjusted -- the value for the first category or the second category. This means that you will need more than one IF statement in your COMPUTE block. If you have 2 categories, then you will need 2 IF statements:&lt;BR /&gt;
[pre]&lt;BR /&gt;
  compute mean;&lt;BR /&gt;
     if _c2_ lt 5 then _c3_ = 0;&lt;BR /&gt;
     if _c4_ lt 5 then _c5_ = 0;&lt;BR /&gt;
  endcomp;&lt;BR /&gt;
[/pre]&lt;BR /&gt;
 &lt;BR /&gt;
Hope this helps clarify things,&lt;BR /&gt;
 &lt;BR /&gt;
cynthia</description>
      <pubDate>Tue, 22 Sep 2009 14:27:35 GMT</pubDate>
      <guid>https://communities.sas.com/t5/ODS-and-Base-Reporting/Edit-values-in-columns-in-proc-report/m-p/71281#M8181</guid>
      <dc:creator>Cynthia_sas</dc:creator>
      <dc:date>2009-09-22T14:27:35Z</dc:date>
    </item>
    <item>
      <title>Re: Edit values in columns in proc report</title>
      <link>https://communities.sas.com/t5/ODS-and-Base-Reporting/Edit-values-in-columns-in-proc-report/m-p/71282#M8182</link>
      <description>Hi&lt;BR /&gt;
&lt;BR /&gt;
Thanks a lot. If I understand it right you have to use the _cx_ variables as references? So if I don´t know the number of across columns, I have to get that before the proc report. &lt;BR /&gt;
&lt;BR /&gt;
I use the proc report in a webapplication, where the user can choose from several group variables.</description>
      <pubDate>Wed, 23 Sep 2009 12:32:06 GMT</pubDate>
      <guid>https://communities.sas.com/t5/ODS-and-Base-Reporting/Edit-values-in-columns-in-proc-report/m-p/71282#M8182</guid>
      <dc:creator>Jennys</dc:creator>
      <dc:date>2009-09-23T12:32:06Z</dc:date>
    </item>
    <item>
      <title>Re: Edit values in columns in proc report</title>
      <link>https://communities.sas.com/t5/ODS-and-Base-Reporting/Edit-values-in-columns-in-proc-report/m-p/71283#M8183</link>
      <description>Hi:&lt;BR /&gt;
  You're going to allow the user to select multiple ACROSS variables??? Or just one or two. In your example, you showed only category as the ACROSS variable, nested with Salary, N and Mean. The GROUP variables in PROC REPORT are what go down the rows -- so if the users select multiple GROUP variables, you would be OK.&lt;BR /&gt;
 &lt;BR /&gt;
  Because the naming system follows a regular pattern, it is possible to write a SAS macro program to generate all the _cx_ statements you need as described in this paper on selected REPORT topics:&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;BR /&gt;
  If you are unfamiliar with the SAS Macro Facility, I recommend this paper as a good introduction:&lt;BR /&gt;
 &lt;A href="http://www2.sas.com/proceedings/sugi28/056-28.pdf" target="_blank"&gt;http://www2.sas.com/proceedings/sugi28/056-28.pdf&lt;/A&gt;&lt;BR /&gt;
&lt;BR /&gt;
 cynthia</description>
      <pubDate>Wed, 23 Sep 2009 14:21:48 GMT</pubDate>
      <guid>https://communities.sas.com/t5/ODS-and-Base-Reporting/Edit-values-in-columns-in-proc-report/m-p/71283#M8183</guid>
      <dc:creator>Cynthia_sas</dc:creator>
      <dc:date>2009-09-23T14:21:48Z</dc:date>
    </item>
  </channel>
</rss>

