Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Mike Lewis on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

proc report help

Status
Not open for further replies.

shenniko

Programmer
Apr 15, 2005
52
US
Hi,

Im still a little new to SAS, and need a little help with the Proc Print...

I have a dataset with the following variables:-

date, region, product, faults, rate, est_rate, idx, urllink2, Outage..

Now in my Proc report i have:-

Code:
ods html
  file="T:\Trac\Robbie\Sas\Outages.html"
  style=style.newfont_robbie;

title "<img src='logo2.bmp' align=left> <img src='saslanim.gif' align=right>";
title2 justify=center h=2.5 "&title2.";
title3 justify=center h=2.5 "&title3.";

    * filter the main dataset on franchise and account number and generate the report ;
    proc report data=mysas.Exceptions_With_Outages nowindows ls=200 nocenter headskip split='\';
      columns date region product faults rate est_rate idx urllink2;
      define date / group FORMAT=ddmmyy10. WIDTH=10   SPACING=2   CENTER "Date" ;
      define region / group FORMAT=$21. WIDTH=21   SPACING=2   CENTER "Region" ;
      define product / display FORMAT=$7. WIDTH=7   SPACING=2   CENTER "Product" ;
      define faults / display FORMAT=9. WIDTH=9   SPACING=2   CENTER "Number\Of Faults" ;
      define rate / sum FORMAT=percent12.5 WIDTH=12   SPACING=2   CENTER "Fault\Rate" ;
      define est_rate / display FORMAT=percent12.5 WIDTH=12  SPACING=2   CENTER "Expected\Fault Rate" ;
      define idx / display FORMAT=9.7 WIDTH=10   SPACING=2   CENTER 'Index %age' ;
      define urllink2 / display FORMAT=$200. WIDTH=100   SPACING=2   CENTER "Details" ;

		compute after region;
			line ' ';
		endcomp;

    run;
ods html close;
ods listing close;

Which will generate me a nice report and include a new line when the region changes..

But what i want is.. when the region changes to insert the "Outage" variable where the line ' ' statement is..

Can anyone help?

thanks in advance

Shenn
 
Shenn,
Do you want to add up the amount of Outages per region? This is what you would use the LINE statement for. Remember that the line executes after the statistics are done. There is no longer any value in the outage var when the line statement is executed.

If you wanted a sum of the outages in that region what I would do is use an alias. In your column statment insert the following new_var=outages.

In you define statements:
define region / group;
define new_var / sum;

and now you can use the LINE statement the way you wnated to:
compute after region;
LINE new_var;
endcomp;

Good luck!
Klaz
 
Hi, thanks for the quick responce,

But the Outage Variable was a character string.. Which ive finally managed to figure out by using:-

Code:
     compute after outage / style(LINES)={background=#B0B0B0};
        call define('_C9_',"STYLE","style={background=#B0B0B0 foreground=black}");
        line '<DIV align=left><ul>' outage $3200.;
        line '</DIV></ul>';
      endcomp;

BUT.. Ive now been tasked with something else...

I need to something a little similar.. but i cant get it to work..

I need to compute after Date, so it would look something like this:-

Code:
    compute before Date;
        call define('_C10_',"STYLE","style={background=#B0B0B0 foreground=black}");
        line '<DIV align=left><ul>' National $3200.;
        line '</DIV></ul>';
	endcomp;

But what ive found is, when you compute after/before one veriable, you cant display another veriable..

The code above will just enter a blank line every time the date changes.

Any ideas?

Thanks in advance

Shenn
 
One thing to note is that the order the variables are listed in your "Columns" statement, is the order that they are used. If you put a later variable in a compute statement, it will be missing.

IE
Code:
  columns a b c d;
  define .....;

  compute after b;
     line c;
  endcomp;
your line here will always be blank because variable C hasn't been read in yet. Very annoying I know, I had all kinds of fun working this one out some time ago when setting up traffic lighting. To get this to work, you'd need to change the columns statement to

Code:
   columns a c b d;

Enjoy.
 
Hi,

Thanks again for the quick responce,

I've tried what you said, but im still not getting any data displayed, although it is inserting a blank line...

Code below

Code:
    * filter the main dataset on franchise and account number and generate the report ;
    proc report data=Outage_Exceptions nowindows ls=200 nocenter headskip split='\';
	  columns date National region product faults rate est_rate idx urllink2 outage ;
	  define date / group FORMAT=ddmmyy10. WIDTH=10 SPACING=2 CENTER "Date" ;
	  define National / group noprint LEFT "National";
	  define region / group FORMAT=$21. WIDTH=21 SPACING=2 CENTER "Region" ;
      define product / display FORMAT=$7. WIDTH=7 SPACING=2 CENTER "Product" ;
      define faults / display FORMAT=9. WIDTH=9 SPACING=2 CENTER "Number\Of Faults" ;
      define rate / sum FORMAT=percent12.5 WIDTH=12 SPACING=2 CENTER "Fault\Rate" ;
      define est_rate / display FORMAT=percent12.5 WIDTH=12 SPACING=2 CENTER "Expected\Fault Rate" ;
      define idx / display FORMAT=9.7 WIDTH=10 SPACING=2 CENTER 'Index %age' ;
      define urllink2 / display FORMAT=$200. WIDTH=100 SPACING=2 CENTER "Details" ;
      define outage / group "Outage" noprint LEFT;
	  
    compute before date / style(LINES)={background=#B0B0B0};
        	call define('_C2_',"STYLE","style={background=#B0B0B0 foreground=black}");
        	line '<DIV align=left><ul>' outage $3200.;
        	line '</DIV></ul>';
	endcomp;

     compute after outage / style(LINES)={background=#B0B0B0};
        call define('_C9_',"STYLE","style={background=#B0B0B0 foreground=black}");
        line '<DIV align=left><ul>' outage $3200.;
        line '</DIV></ul>';
      endcomp;
	run;

Any Idea's?

thanks in advance

Shenn
 
Are there any warning messages? You have outage formatted to $3200, but only have a linesize of 200 characters, which might cause a little confusion.
Try cutting out the call define statement, and the html tags and just work on getting outage displayed as they may be confusing the image. Once you've got the syntax working, put all that stuff back in.

The "compute before date" step, I'm pretty sure won't work because you are trying to use OUTAGE before it is listed. If you moved outage to the start of the columns statement, it should work.

As an example. I had this set up for some traffic lighting on a report going into Excel
Code:
   column row_number audit_id orgn_id financial_year workplace_id calc_dt ams_commenced_dt start_dt ;

   define.....; 

   compute start_dt;
     if start_dt ne ams_commenced_dt then call define(_col_,"style","style={background=red font_weight=bold}");
   endcomp;

This works, but originally I had defined the compute step as:-
Code:
   compute ams_commenced_dt;
     if ams_commenced_dt ne start_dt then call define(_col_,"style","style={background=red font_weight=bold}");
   endcomp;

This highlighted the whole column because when it processed ams_commenced_date, it hadn't looked at start_dt yet and treated it as missing. The SAS Online doc says this:

CAUTION:
The position of a computed variable is important. PROC REPORT assigns values to the columns in a row of a report from left to right. Consequently, you cannot base the calculation of a computed variable on any variable that appears to its right in the report.

I can't see anything particularly wrong with the second compute step, my advice as I said is to trim out all the excess html, then play around with the order of the definitions. Also, if you're outputting it to an html file, still check the .LST file as this may help debug. There's not alot more I can do without having the data unfortunately.
Let us know how you get on.

 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top