Trying to send a data _null_ costomized report to _webout in Enterprise Guide as a stored process in html stream output format.

Accepted Solution Solved
Reply
Occasional Contributor
Posts: 13
Accepted Solution

Trying to send a data _null_ costomized report to _webout in Enterprise Guide as a stored process in html stream output format.

The report crashes and I get a disordered horizontal output that looks like this: ------------------------------------Honda $20000 $13000  ------------------------------------BMW  $12000 $26000 ----------------------------------------Toyota $23444 $21000 .

Why is the layout of the report changing ?

Want the output to look like this:

-------------------------------------

Honda      BMW     Toyota

-------------------------------------

$20000    $12000   $23444

$13000    $26000   $21000

------------------------------------

Or to be in a table format.

Thanks in advance  for  ideas and suggestions.


Accepted Solutions
Solution
‎08-22-2015 01:45 PM
SAS Super FREQ
Posts: 8,721

Re: Trying to send a data _null_ costomized report to _webout in Enterprise Guide as a stored process in html stream output format.

Hi:

  When you first started this post, you said that you were eventually going to be doing this report as a stored process. You do NOT need to use DATA _NULL_ and _webout in a stored process. Generally, a stored process will have issues when you use _webout because the stored process macros that you need to ALSO use (%STPBEGIN/%STPEND) which need to be in your stored process are ALSO writing to _webout and so with the DATA _NULL_ approach in a stored process, your DATA step use of _webout will conflict with the %STPBEGIN use of _webout.

  You should be able to run this as a stored process from EG. For example, a simple stored process using SASHELP.CLASS would be like this:

*ProcessBody;

%let _odsstyle=sasweb;

%let _odsstylesheet=;

%stpbegin;

  proc print data=sashelp.class noobs;

  title 'This is a stored process';

  run;

%stpend;

  Since PUT in a DATA _NULL_ to _WEBOUT will not typically work in a stored process, you would need to do something like this. It seems to me that the Journal style will give you the lines you want underneath and above the table:

*ProcessBody;

  

data carsale;

  length car $20 desc $30;

  infile datalines dlm=',' dsd;

  input car $ amt  desc $;

return;

datalines;

Honda,40000, "Cars without Insurance"

BMW,140000,"Cars with Insurance"

;

run;

%let _odsstyle=journal;

%let _odsstylesheet=;

%stpbegin;

  proc print data=sashelp.carsale noobs;

  title 'This is a stored process with journal style';

  run;

%stpend;

  There is a note in the documentation about DATA _NULL_ and PUT statements to _webout. I suggest you review the documentation here: SAS(R) 9.3 Stored Processes: Developer's Guide where it explicitly explains that:

                                   "If you are writing to _WEBOUT by

                                 using PUT statements while ODS has _WEBOUT open, when you execute

                                 the code the PUT statement data might be out of sequence with the

                                 data that is generated by ODS. This problem occurs with both  SAS/IntrNet applications and stored

                                 processes.. . .  This problem occurs because both your code and

                                 ODS are opening the same fileref at the same time."

There is also this Tech Support note: 13599 - "ERROR: File is in use" message when running a Stored Process

In my opinion, you should probably abandon the DATA _NULL_/PUT approach if this is going to be a stored process. Otherwise, if you absolutely MUST use _WEBOUT and DATA _NULL_, then I suggest you open a track with Tech Support. PUT statement methods that work with regular SAS and EG will typically not work in a stored process.

cynthia

View solution in original post


All Replies
Grand Advisor
Posts: 10,251

Re: Trying to send a data _null_ costomized report to _webout in Enterprise Guide as a stored process in html stream output format.

What doe the code look like that is generating the output?

Is there an ODS destination involved? if so what are the options.

Occasional Contributor
Posts: 13

Re: Trying to send a data _null_ costomized report to _webout in Enterprise Guide as a stored process in html stream output format.

hi ballardw,

Thanks for reply.

my _webout code looks is this below:

ods html;

data _null_;

Infile "I put the filename here";

File _webout;

Input;

put _infile_;

run;

ods html close;

Grand Advisor
Posts: 10,251

Re: Trying to send a data _null_ costomized report to _webout in Enterprise Guide as a stored process in html stream output format.

It looks like you need to check your input file. Since your code is basically just putting the input line directly to the output then the contents of the input are an issue.

It looks like you may be taking text output by the listing and re-reading it. If that is the case it appears that you are losing the carriage controls. if that is the case suggest investigating something like:

ods html path="<path to output location>" file="<specific output file goes here>";

<your procedure that generated the output>

ods html close;

Esteemed Advisor
Posts: 6,706

Re: Trying to send a data _null_ costomized report to _webout in Enterprise Guide as a stored process in html stream output format.

If you use data _null_, you basically create raw output and write it directly to the file, without ODS playing a role at all. So it is your responsibility to create valid HTML code. Like:

data _null_;

set whatever end=done;

if _n_ = 1  then do;

  put '<html>';

  put '<head>';

* header information, like meta tags, etc ;

  put '</head';

  put '<body>';

  put '<table>';

end;

put '<tr>';

put '<td>'@;

put var1;

put '</td>';

put '</tr>';

if done then do;

  put '</table>';

  put '</body>';

  put '</html>';

end;

run;

Now, if you use ODS HTML file=_webout;, then you need to create output for the ODS destination, with SAS procedures that create typical SAS output: proc sql, proc print, proc report, .....

---------------------------------------------------------------------------------------------
Maxims of Maximally Efficient SAS Programmers
Occasional Contributor
Posts: 13

Re: Trying to send a data _null_ costomized report to _webout in Enterprise Guide as a stored process in html stream output format.

Hi ballardw,

still trying to figure this out. Actullay please allow me to describe my issue in much more details.

let's say I have a single row SAS output dataset 'work.carsale' like this below:

auction_location    old_cars         new_cars       

GA                        $40000           $140000           

I want to build a streaming html report from that output and store it as a process in Enterprise Guide.

The final output for the user should should be html and  look like below;

Table:weekly car Inventory

Brands                   Amounts                   Description

__________________________________________________

Honda                    $40000                     Cars without Insurance

BMW                      $140000                   Cars with Insurance

__________________________________________________

My input file to the _webout data _null_ steps derive from the code below:

path="R:\Dir\New_output\"   File=Ready.sas;

%let z=%Str (20); y=%Str(50);

Data _null_;

set carsale;

put // 'Table:Weekly Car Inventory' //;

Put '_________________________________';

Put / 'Brands'  &z Amounts' &y  'Description' /;

Put '_________________________________';

Put / 'Honda'  &z Old_cars  &y 'Cars Without Insurance' / 'BMW'  &z  New_Cars  &y 'Cars with Insurance' /;

Put '_________________________________';

run;

Then I procede with:

ODS html;

Data _null_;

Infile "R:\Dir\New_output\Ready.sas";

File _webout;

Input;

Put _infile_;

run;

ODS html close;

All this is done in EG building a stored process. but unable to get the final outpout straight. I believe my problem is coming from the input file 'Ready.sas' like you mentioned earlier. that's where I would need help I think. Not quiet sure whats going on. still researching that.

Thanks for your attentions.

Esteemed Advisor
Posts: 6,706

Re: Trying to send a data _null_ costomized report to _webout in Enterprise Guide as a stored process in html stream output format.

As I already stated, in order to make your output look "pretty" in a browser, you need to create valid and "pretty" HTML code. You do this either by making use of the capabilities of ODS HTML and, say, PROC REPORT, or by generating the necessary HTML code "by hand" in a data _null_ step. Without proper HTML tags, your output will come out as a big bowl of spaghetti.

PUT statements in a data step do NOT go through the processing of the Output Delivery System. The data is sent to the output file/destination "as is".

---------------------------------------------------------------------------------------------
Maxims of Maximally Efficient SAS Programmers
Occasional Contributor
Posts: 13

Re: Trying to send a data _null_ costomized report to _webout in Enterprise Guide as a stored process in html stream output format.

Thanks Kurt,

I will continue attempting the data _null_ method by writing HTML code using your suggestion. If It does not work then I would switch to a PROC Report method. Please let me know you come across some additional hints.

Occasional Contributor
Posts: 13

Re: Trying to send a data _null_ costomized report to _webout in Enterprise Guide as a stored process in html stream output format.

Kurt,

(I temporary give up on the data Data _null_  method.). Want to try PROC report now.

How would you go by using the  PROC report method? Any hint you can give me? It seems to be complicated because the final report has new variable names such as Brands, Amounts, Description and new observations such as Honda, BMW, Cars without Insurance, cars with Insurance, which are not part of the original dataset table work.carsale.

Thanks

Grand Advisor
Posts: 10,251

Re: Trying to send a data _null_ costomized report to _webout in Enterprise Guide as a stored process in html stream output format.

Another approach is using FILE PRINT ODS. With the correct ODS destination but I really think that you should look at the Report procedures to get additional appearance control. "Printing" a bunch of underscore characters would not look as nice as table results from Proc Report/ Tabulate or even Print.

What requirement drives the use of data _null_ and put to text?

Occasional Contributor
Posts: 13

Re: Trying to send a data _null_ costomized report to _webout in Enterprise Guide as a stored process in html stream output format.

There are no requirements. I was using data _null_ and put because I think it is more flexible when it comes to including new data points such as the variables Brands, Lifetime Impact, measure and new obs such as Honda, Bmw, cars with Insurance , etc.. all of which were not part of the original dataset work.carsale.  I usually make an easy use of PROC report when the dataset table has all variables and observations.  But this time it is different. That's where my issue is. Not sure how to include them in the proc report procedure. I tried to use compute after; and then line statement but its not working out.

Occasional Contributor
Posts: 13

Re: Trying to send a data _null_ costomized report to _webout in Enterprise Guide as a stored process in html stream output format.

Hi Kurt,

How would you go by using PROC report for this type of report. It comes out to be challenging because the final report include new variables such as Brands, Lifetime Impact, measure, and also new observations such as Honda, BMW, Cars without Insurance, cars with Insurance,  which are not part of the original dataset table work.carsale. Any hint?

Grand Advisor
Posts: 10,251

Re: Trying to send a data _null_ costomized report to _webout in Enterprise Guide as a stored process in html stream output format.

If you are getting your data so that you are basically just displaying the rows, I think proc print might be sufficient. You don't need to tell it ANY variables;

Take a look at:

ods html style=journal;

proc print data=sashelp.cars noobs label;

title "Table: Car summary";

run;title;

If you have nice Labels for your variables then you get quite nice output.

And you can do column sums in proc print though not a lot of fancier stuff.

Occasional Contributor
Posts: 13

Re: Trying to send a data _null_ costomized report to _webout in Enterprise Guide as a stored process in html stream output format.

But Proc print can not be used in this case because the output was generated by a _null_ step and it is an infile output. Not an actual dataset where we can say Proc print data=  . What do you think?

Grand Advisor
Posts: 10,251

Re: Trying to send a data _null_ costomized report to _webout in Enterprise Guide as a stored process in html stream output format.

Which was a CHOICE that you made.

Data _null_;

set carsale;

put // 'Table:Weekly Car Inventory' //;

Put '_________________________________';

Put / 'Brands'  &z Amounts' &y  'Description' /;

Put '_________________________________';

Put / 'Honda'  &z Old_cars  &y 'Cars Without Insurance' / 'BMW'  &z  New_Cars  &y 'Cars with Insurance' /;

Put '_________________________________';

run;

Then I procede with:

ODS html;

Data _null_;

Infile "R:\Dir\New

Shows a data set CARSALE as your data source.

Then you write to a file.

Then you read that file and write a different file. Very convoluted and I do not see why Proc Print data=carsales doesn't work.

Perhaps you need a little manipulation of the data.

It may be time to post some example starting data and rethink the current process entirely. And describe what the macro variables represent and where they come from.

☑ This topic is SOLVED.

Need further help from the community? Please ask a new question.

Discussion stats
  • 18 replies
  • 641 views
  • 10 likes
  • 4 in conversation