<?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 in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/proc-report/m-p/16924#M2408</link>
    <description>Nope.&lt;BR /&gt;
The idea is:&lt;BR /&gt;
if physicians A B C are in terrid 111 and A has flag Y  and their respective totals are 500 600 500 each then we show the summary as:&lt;BR /&gt;
&lt;BR /&gt;
terrid Physician     total&lt;BR /&gt;
111     B                600&lt;BR /&gt;
111     C                500&lt;BR /&gt;
-------------------------------------&lt;BR /&gt;
111(total)               1600      &lt;BR /&gt;
&lt;BR /&gt;
we hide A from showing.</description>
    <pubDate>Fri, 13 Nov 2009 20:16:24 GMT</pubDate>
    <dc:creator>SASPhile</dc:creator>
    <dc:date>2009-11-13T20:16:24Z</dc:date>
    <item>
      <title>proc report</title>
      <link>https://communities.sas.com/t5/SAS-Programming/proc-report/m-p/16922#M2406</link>
      <description>In the code shown below:&lt;BR /&gt;
if the flag is 'Y' in stead of highlighting the physician's name in yellow, how to delete, keeping the rest of the logic same.&lt;BR /&gt;
proc report list NOWINDOWS data=crmrk_combine_bsm_final  out=out_final1   HEADLINE MISSING;&lt;BR /&gt;
	COLUMN terrid  bsm physician_name flag year,productgroup,(total_scripts reptot);&lt;BR /&gt;
	where terrid ne '';&lt;BR /&gt;
	define terrid/group	;&lt;BR /&gt;
	define bsm/group	;&lt;BR /&gt;
	DEFINE physician_name / group	;&lt;BR /&gt;
	DEFINE year / across ''	;&lt;BR /&gt;
	DEFINE productgroup / across;&lt;BR /&gt;
	DEFINE total_scripts / sum format=comma12. noprint ' ';&lt;BR /&gt;
	DEFINE flag/group noprint;&lt;BR /&gt;
	define reptot/computed  format=comma12.  ' ';&lt;BR /&gt;
	 compute reptot;&lt;BR /&gt;
	 if flag='Y' then do;&lt;BR /&gt;
    _C6_=.;&lt;BR /&gt;
   _C8_=.;&lt;BR /&gt;
   _C10_=.;&lt;BR /&gt;
  _C12_=.;&lt;BR /&gt;
  _C14_=.;&lt;BR /&gt;
  _C16_=.;&lt;BR /&gt;
 call define("physician_name",'style','style=[background=yellow]');&lt;BR /&gt;
   end;&lt;BR /&gt;
   else do;&lt;BR /&gt;
   _C6_=_C5_;&lt;BR /&gt;
   _C8_=_C7_;&lt;BR /&gt;
   _C10_=_C9_;&lt;BR /&gt;
   _c12_=_c11_;&lt;BR /&gt;
   _c14_=_c13_;&lt;BR /&gt;
   _c16_=_c15_;&lt;BR /&gt;
&lt;BR /&gt;
   end;&lt;BR /&gt;
  endcomp;&lt;BR /&gt;
run</description>
      <pubDate>Fri, 13 Nov 2009 18:30:38 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/proc-report/m-p/16922#M2406</guid>
      <dc:creator>SASPhile</dc:creator>
      <dc:date>2009-11-13T18:30:38Z</dc:date>
    </item>
    <item>
      <title>Re: proc report</title>
      <link>https://communities.sas.com/t5/SAS-Programming/proc-report/m-p/16923#M2407</link>
      <description>can you do data=crmrk_combine_bsm_final(where=(flag^='Y')) ?</description>
      <pubDate>Fri, 13 Nov 2009 20:09:47 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/proc-report/m-p/16923#M2407</guid>
      <dc:creator>abdullala</dc:creator>
      <dc:date>2009-11-13T20:09:47Z</dc:date>
    </item>
    <item>
      <title>Re: proc report</title>
      <link>https://communities.sas.com/t5/SAS-Programming/proc-report/m-p/16924#M2408</link>
      <description>Nope.&lt;BR /&gt;
The idea is:&lt;BR /&gt;
if physicians A B C are in terrid 111 and A has flag Y  and their respective totals are 500 600 500 each then we show the summary as:&lt;BR /&gt;
&lt;BR /&gt;
terrid Physician     total&lt;BR /&gt;
111     B                600&lt;BR /&gt;
111     C                500&lt;BR /&gt;
-------------------------------------&lt;BR /&gt;
111(total)               1600      &lt;BR /&gt;
&lt;BR /&gt;
we hide A from showing.</description>
      <pubDate>Fri, 13 Nov 2009 20:16:24 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/proc-report/m-p/16924#M2408</guid>
      <dc:creator>SASPhile</dc:creator>
      <dc:date>2009-11-13T20:16:24Z</dc:date>
    </item>
    <item>
      <title>Re: proc report</title>
      <link>https://communities.sas.com/t5/SAS-Programming/proc-report/m-p/16925#M2409</link>
      <description>I'm curious how anybody would know about the "missing" 500. When I look at your mini-report and see 600 and 500, I really wonder how those 2 numbers added up to 1600.&lt;BR /&gt;
 &lt;BR /&gt;
But, you can't delete a report row from PROC REPORT -- once the procedure has started (which is what it seems you want to do). You'll have to pre-summarize/pre-process your data prior to PROC REPORT, get it all massaged and organized the way you want. I'd probably summarize and delete the rows all at the same time in a DATA step program.&lt;BR /&gt;
 &lt;BR /&gt;
cynthia</description>
      <pubDate>Fri, 13 Nov 2009 20:29:05 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/proc-report/m-p/16925#M2409</guid>
      <dc:creator>Cynthia_sas</dc:creator>
      <dc:date>2009-11-13T20:29:05Z</dc:date>
    </item>
    <item>
      <title>Re: proc report</title>
      <link>https://communities.sas.com/t5/SAS-Programming/proc-report/m-p/16926#M2410</link>
      <description>well thats how the report is required.To hide phycisians whose flag is Y and yet add their scripts to the total.</description>
      <pubDate>Fri, 13 Nov 2009 20:48:05 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/proc-report/m-p/16926#M2410</guid>
      <dc:creator>SASPhile</dc:creator>
      <dc:date>2009-11-13T20:48:05Z</dc:date>
    </item>
    <item>
      <title>Re: proc report</title>
      <link>https://communities.sas.com/t5/SAS-Programming/proc-report/m-p/16927#M2411</link>
      <description>Interesting. You'll just need to pre-process the data....if the obs with flag=Y are passed to PROC REPORT, then PROC REPORT will want to include them on the report.&lt;BR /&gt;
 &lt;BR /&gt;
cynthia</description>
      <pubDate>Fri, 13 Nov 2009 21:10:23 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/proc-report/m-p/16927#M2411</guid>
      <dc:creator>Cynthia_sas</dc:creator>
      <dc:date>2009-11-13T21:10:23Z</dc:date>
    </item>
    <item>
      <title>Re: proc report</title>
      <link>https://communities.sas.com/t5/SAS-Programming/proc-report/m-p/16928#M2412</link>
      <description>is there a way to supress the record if physician eq  ' '?</description>
      <pubDate>Fri, 13 Nov 2009 22:10:24 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/proc-report/m-p/16928#M2412</guid>
      <dc:creator>SASPhile</dc:creator>
      <dc:date>2009-11-13T22:10:24Z</dc:date>
    </item>
    <item>
      <title>Re: proc report</title>
      <link>https://communities.sas.com/t5/SAS-Programming/proc-report/m-p/16929#M2413</link>
      <description>It depends on what you mean by "record" -- if by "record" you mean the observation in a dataset and deleting it with a DATA step program...then, yes... you could delete observations from a dataset where the value for the physician variable was missing or blank.&lt;BR /&gt;
 &lt;BR /&gt;
On the other hand, if by "record" you mean suppressing a report row that is being generated with PROC REPORT. You cannot suppress or delete a report row as PROC REPORT is generating the REPORT.&lt;BR /&gt;
 &lt;BR /&gt;
For example, if you have this data:&lt;BR /&gt;
[pre]&lt;BR /&gt;
Terrid Phys total flag&lt;BR /&gt;
 111     A   500   Y&lt;BR /&gt;
 111     B   600   N&lt;BR /&gt;
 111     C   500   N&lt;BR /&gt;
 112     D   100   N&lt;BR /&gt;
 112     E   100   Y&lt;BR /&gt;
 112     C   400   N&lt;BR /&gt;
 112     F   200   N&lt;BR /&gt;
[/pre]&lt;BR /&gt;
                                                &lt;BR /&gt;
  Then you have to decide whether you want a DETAIL report -- where you have one report row for every observation in the original data set or whether you want a SUMMARY report, where you have one report row which represents the summary for a "group" of observations (such as those observations grouped by TERRID).&lt;BR /&gt;
               &lt;BR /&gt;
If you want a DETAIL report -- then by default -- PROC REPORT would DISPLAY every observation -- unless you use a WHERE statement or pre-process the data (such as to get rid of the obs where FLAG = Y). Your choices for a DETAIL report are to DISPLAY every value for every obs -- where PROC REPORT respects the original ordering of the data. OR to use a variable, such as TERRID as an ORDER variable, in which case, the repetitious display of TERRID would be suppressed on some report rows.&lt;BR /&gt;
 &lt;BR /&gt;
It is easy with PROC REPORT, especially when you are generating a DETAIL report, to forget that PROC REPORT is building a report row for EVERY observation and then, adding summary lines, as instructed by your BREAK and RBREAK statements. If, on the other hand, you wanted a SUMMARY REPORT from the above data, then you would define TERRID as a GROUP item on the REPORT. Without the PHYS column on the report, the above data would collapse down to 2 report rows -- one row for TERRID 111 and a second row for TERRID 112. If you add a final summary line or overall report break to the report, then you'd have 3 report rows on your SUMMARY or GROUP report.&lt;BR /&gt;
 &lt;BR /&gt;
So the answer to your question really depends on whether you are trying to delete a REPORT row or whether you are trying to delete an observation -before- PROC REPORT handles the data.&lt;BR /&gt;
 &lt;BR /&gt;
cynthia&lt;BR /&gt;
            &lt;BR /&gt;
 &lt;BR /&gt;
[pre]&lt;BR /&gt;
data scrip;&lt;BR /&gt;
  length Phys $15;&lt;BR /&gt;
  infile datalines;&lt;BR /&gt;
  input terrid Phys $ total flag $;&lt;BR /&gt;
return;&lt;BR /&gt;
datalines;&lt;BR /&gt;
111 A 500  Y&lt;BR /&gt;
111 B 600  N&lt;BR /&gt;
111 C 500  N&lt;BR /&gt;
112 D 100  N&lt;BR /&gt;
112 E 100  Y&lt;BR /&gt;
112 C 400  N&lt;BR /&gt;
112 F 200  N&lt;BR /&gt;
;&lt;BR /&gt;
run;&lt;BR /&gt;
                    &lt;BR /&gt;
ods listing close;&lt;BR /&gt;
options nodate nonumber center;&lt;BR /&gt;
ods html file='terrid.html' style=sasweb;&lt;BR /&gt;
proc report data=scrip nowd;&lt;BR /&gt;
  title 'TERRID and Phys as ORDER variables';&lt;BR /&gt;
  column terrid phys total;&lt;BR /&gt;
  define terrid / order;&lt;BR /&gt;
  define phys / order;&lt;BR /&gt;
  define total / sum;&lt;BR /&gt;
  break after terrid / summarize;&lt;BR /&gt;
  rbreak after/ summarize;&lt;BR /&gt;
  compute after terrid;&lt;BR /&gt;
    phys = 'Total';&lt;BR /&gt;
	line ' ';&lt;BR /&gt;
  endcomp;&lt;BR /&gt;
  compute after;&lt;BR /&gt;
    phys = 'Total';&lt;BR /&gt;
  endcomp;&lt;BR /&gt;
run;&lt;BR /&gt;
                     &lt;BR /&gt;
proc report data=scrip nowd;&lt;BR /&gt;
  title 'TERRID as group variable';&lt;BR /&gt;
  column terrid t_id n total;&lt;BR /&gt;
  define terrid / group noprint;&lt;BR /&gt;
  define t_id / computed 'Terrid';&lt;BR /&gt;
  define n / 'Phys Count';&lt;BR /&gt;
  define total / sum;&lt;BR /&gt;
  rbreak after / summarize;&lt;BR /&gt;
  compute t_id / character length=8;&lt;BR /&gt;
    t_id = put(terrid,3.0);&lt;BR /&gt;
  endcomp;&lt;BR /&gt;
  compute after;&lt;BR /&gt;
    t_id = 'Total';&lt;BR /&gt;
  endcomp;&lt;BR /&gt;
run;&lt;BR /&gt;
ods html close;&lt;BR /&gt;
[/pre]</description>
      <pubDate>Fri, 13 Nov 2009 23:59:20 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/proc-report/m-p/16929#M2413</guid>
      <dc:creator>Cynthia_sas</dc:creator>
      <dc:date>2009-11-13T23:59:20Z</dc:date>
    </item>
    <item>
      <title>Re: proc report</title>
      <link>https://communities.sas.com/t5/SAS-Programming/proc-report/m-p/16930#M2414</link>
      <description>SASPhile&lt;BR /&gt;
when I have had to do something similar, rather than delete the whole line, I collapsed all lines to be excluded into a single entry labelled something like "others" on a pie chart. &lt;BR /&gt;
Another comparable data model would be the phone bill items below the 10cents level. There is probably some latin phrase to describe it;-)&lt;BR /&gt;
My preprocessing summarised the "to be hidden" items. with the same cross-classifications as the report then merged those "hidden items totals" back among the "to be shown items". After that the summary lines were treated like normal data lines in the report.&lt;BR /&gt;
It might be possible to achieve this kind of data handling in proc report, but it is beyond my imagination,how!&lt;BR /&gt;
I imagine most of us could come up with working code, if that would be a satisfactory solution design for you and your customer/boss.&lt;BR /&gt;
 &lt;BR /&gt;
hth&lt;BR /&gt;
PeterC</description>
      <pubDate>Sat, 14 Nov 2009 09:16:15 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/proc-report/m-p/16930#M2414</guid>
      <dc:creator>Peter_C</dc:creator>
      <dc:date>2009-11-14T09:16:15Z</dc:date>
    </item>
    <item>
      <title>Re: proc report</title>
      <link>https://communities.sas.com/t5/SAS-Programming/proc-report/m-p/16931#M2415</link>
      <description>thank you Cynthia&lt;BR /&gt;
You've clarified the solution for me!&lt;BR /&gt;
Preprocess the data, setting physician details to 'hidden', say. Then make proc report perform a summary - including physician identity at the lowest level. Those flagged Y will be counted but not identified.&lt;BR /&gt;
 great.&lt;BR /&gt;
 &lt;BR /&gt;
PeterC</description>
      <pubDate>Sat, 14 Nov 2009 09:29:22 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/proc-report/m-p/16931#M2415</guid>
      <dc:creator>Peter_C</dc:creator>
      <dc:date>2009-11-14T09:29:22Z</dc:date>
    </item>
    <item>
      <title>Re: proc report</title>
      <link>https://communities.sas.com/t5/SAS-Programming/proc-report/m-p/16932#M2416</link>
      <description>Hi cunthia,&lt;BR /&gt;
 The output for the first proc report is this:&lt;BR /&gt;
terrid	Phys	total&lt;BR /&gt;
111	A	500&lt;BR /&gt;
	B	600&lt;BR /&gt;
	C	500&lt;BR /&gt;
111	Total	1600&lt;BR /&gt;
		&lt;BR /&gt;
112	C	400&lt;BR /&gt;
	D	100&lt;BR /&gt;
	E	100&lt;BR /&gt;
	F	200&lt;BR /&gt;
112	Total	800&lt;BR /&gt;
		&lt;BR /&gt;
	Total	2400&lt;BR /&gt;
&lt;BR /&gt;
&lt;BR /&gt;
I'm trying for this:(A &amp;amp; E are not shown).but total at terrid level includes the sum of all physicians,.&lt;BR /&gt;
we may say not displaying A and E or hiding A &amp;amp; E.&lt;BR /&gt;
terrid	Phys	total&lt;BR /&gt;
111	B	600&lt;BR /&gt;
	C	500&lt;BR /&gt;
111	Total	1600&lt;BR /&gt;
		&lt;BR /&gt;
112	C	400&lt;BR /&gt;
	D	100&lt;BR /&gt;
	F	200&lt;BR /&gt;
112	Total	800&lt;BR /&gt;
		&lt;BR /&gt;
	Total	2400</description>
      <pubDate>Mon, 16 Nov 2009 14:47:28 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/proc-report/m-p/16932#M2416</guid>
      <dc:creator>SASPhile</dc:creator>
      <dc:date>2009-11-16T14:47:28Z</dc:date>
    </item>
    <item>
      <title>Re: proc report</title>
      <link>https://communities.sas.com/t5/SAS-Programming/proc-report/m-p/16933#M2417</link>
      <description>Hi:&lt;BR /&gt;
  As I said, you're not going to be able to hide those report rows using PROC REPORT techniques. You'll have to pre-process the data. &lt;BR /&gt;
 &lt;BR /&gt;
  You could either use PROC MEANS to summarize the Y flag totals (or PROC SQL or PROC TABULATE) and then create a subset of just the N flag observations. You could then either MERGE or use PROC SQL to merge the Y totals back with the N-only observations -- you'd have to be careful to only grab the Y totals once. But then you could pass the "massaged" data to PROC REPORT. &lt;BR /&gt;
 &lt;BR /&gt;
  Imagine that your final "massaged" data looked something like this:&lt;BR /&gt;
[pre]&lt;BR /&gt;
terrid  Phys    FLAG    total    add_y    add_cnt &lt;BR /&gt;
 111     B        N      600      500        1&lt;BR /&gt;
 111     C        N      500        .        .&lt;BR /&gt;
 112     D        N      100      100        1&lt;BR /&gt;
 112     C        N      400        .        .&lt;BR /&gt;
 112     F        N      200        .        .&lt;BR /&gt;
[/pre]&lt;BR /&gt;
                     &lt;BR /&gt;
This data set has only the N flag observations. But the first TERRID observation also holds the total for ADD_Y (this would have come from PROC MEANS) and the ADD_CNT var holds the total count of Y flags for each TERRID (just in case you wanted to go back to the original data and double check).&lt;BR /&gt;
                      &lt;BR /&gt;
  With this kind of structure to the data, you can now have a compute block that takes the ADD_Y sum and adds it to the TOTAL sum at the summary break. Something like this COLUMN statement and COMPUTE block:&lt;BR /&gt;
[pre]&lt;BR /&gt;
  column terrid  Phys add_y total;&lt;BR /&gt;
 . . . more code . . .&lt;BR /&gt;
  define add_y/ sum noprint;&lt;BR /&gt;
  define total / sum;&lt;BR /&gt;
  break after terrid / summarize;&lt;BR /&gt;
  compute after terrid;&lt;BR /&gt;
    total.sum + add_y.sum;&lt;BR /&gt;
    line ' ' ;&lt;BR /&gt;
  endcomp;&lt;BR /&gt;
  rbreak after / summarize;&lt;BR /&gt;
  compute after;&lt;BR /&gt;
    total.sum + add_y.sum;&lt;BR /&gt;
  endcomp;&lt;BR /&gt;
[/pre]&lt;BR /&gt;
                                                                        &lt;BR /&gt;
But the PROC REPORT is not hiding anything -- your pre-processing gets rid of the Y observations, but makes their totals available as a NOPRINT item -- once the "massaged" data has the suggested structure. And, even though the data row for physician B and the data row for physician D is "holding" the Y flag total, the physician total is unchanged and since the ADD_Y item is a NOPRINT item, it will only be seen or included in the summary line -- it has no impact on the individual physician report row.&lt;BR /&gt;
 &lt;BR /&gt;
cynthia</description>
      <pubDate>Mon, 16 Nov 2009 19:57:02 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/proc-report/m-p/16933#M2417</guid>
      <dc:creator>Cynthia_sas</dc:creator>
      <dc:date>2009-11-16T19:57:02Z</dc:date>
    </item>
  </channel>
</rss>

