DATA Step, Macro, Functions and more

insert a table into HTML page

Reply
Contributor
Posts: 22

insert a table into HTML page


Hi,

I am preparing an HTML report in SAS on Enterprise Guide. It is mostly a details entering page with drop down and textboxes. I was able to use Macros for setting up the dropdowns. Now I need to display a table on the html page. The table has to be positioned on a particular part of the page and hence the code for the table display has to be within the HTML code.

Kindly suggest how I can display an entire table from database on to an HTML page in SAS EG.

Thanks in advance.

Super User
Super User
Posts: 7,970

Re: insert a table into HTML page

Posted in reply to Anand6666

To do what?  Is it just for display, will you need update/refresh/enter data, etc.  If its simply a display, then just add in the tags, and data from your dataset when you write the HTML file, example here: HTML Tables

If its other, then you may want to look at PHP scripting, with a javascript handler.

Contributor
Posts: 22

Re: insert a table into HTML page

Hi, I need to just display data from a table depending on a condition on to the HTML page.

I am not sure how I can do that with within the HTML tags.. like I am displaying the database/dataset details as a column of a HTML table element. Any hints as to how I can achieve it.

Super User
Super User
Posts: 7,970

Re: insert a table into HTML page

Posted in reply to Anand6666

So your not putting data out when the report is generated then.  What you are talking about is a web page with user interaction which loads data from a database.  This is far more complicated then just creating a HTML document.  You could look at PHP scripting, which is used for connecting to databases via web pages: http://en.wikipedia.org/wiki/PHP

Using Javascript/VBScript coding within you HTML page.  Or there is ASP.

These are more advanced topics however, and out of scope of a SAS forum.

Maybe you need one of the other packages that SAS offers, Web Report Studio for example?

Super User
Posts: 7,809

Re: insert a table into HTML page

Posted in reply to Anand6666

Looks like the perfect case for a stored process run via the STP server and the /SASStoredProcess URL

---------------------------------------------------------------------------------------------
Maxims of Maximally Efficient SAS Programmers
Contributor
Posts: 22

Re: insert a table into HTML page

Posted in reply to KurtBremser

Hi Kurt,

I am using Stored process for the HTML page, since I have to use macros.

Could you elaborate on your idea. I didn't quite understand on how to proceed.

Super User
Posts: 7,809

Re: insert a table into HTML page

Posted in reply to Anand6666

So you already send out the HTML from a STP, and then want it to display an additional table?

Where the original HTML includes a FORM element that lets the user select a table/dataset to display?

Why not call the same STP again, with a parameter that includes the dataset name, and have the STP recreate the HTML page, but now with the table inserted?

---------------------------------------------------------------------------------------------
Maxims of Maximally Efficient SAS Programmers
Contributor
Posts: 22

Re: insert a table into HTML page

Posted in reply to KurtBremser

Hi,

I tried using a proc print and a proc report by defining the PROC statements in a macro and then calling the macro in the HTML part.

but the HTML treats the statements inside as text and just displays the statements on the screen rather than to execute them.

Can you suggest any commands or functionality to execute the macro statements.

Super User
Posts: 7,809

Re: insert a table into HTML page

Posted in reply to Anand6666

a) define your meaning of "macro"

b) you can't just write SAS code into a HTML page and hope it will execute. But you can call a predefined Stored Process via the StoredProcessServer

How have you created the HTML page withe stored process up to now, and how do you invoke it (provide an example)?

---------------------------------------------------------------------------------------------
Maxims of Maximally Efficient SAS Programmers
Contributor
Posts: 22

Re: insert a table into HTML page

Posted in reply to KurtBremser

Hi Kurt,

I had to prepare a report in SAS incorporating HTML. I have made use of textboxes and dropdowns using macro variables as their input, setting the value of the form elements with macro variables in javascript.

I concatenate values from dataset into a macro variable and call the macro variable in the HTML statement and it has been working so far.

I have been trying to use the same idea for displaying the table. defining a proc print statement inside a macro and then calling the macro in the HTML.

sample code:

%macro test ;

proc report data=dataset;

title test;

run;

%mend test;

data _null;

input;

put line;

cards4;

<html>

<head>

</head>

<body>

<form name="ADD_SHARE" method="POST">

<br>

<table>

<tr><td>

%test

</td></tr>

</table>

</form>

</html>

;;;;

run;

Super User
Posts: 7,809

Re: insert a table into HTML page

Posted in reply to Anand6666

Since the macro %test is used within the range of the CARDS statement, its generated text is not considered SAS code, but plain text for the input statement. That's why you see it as text in the web page.

This:

http://support.sas.com/documentation/cdl/en/stpug/67499/PDF/default/stpug.pdf

will help you in developing your stored process.

---------------------------------------------------------------------------------------------
Maxims of Maximally Efficient SAS Programmers
Ask a Question
Discussion stats
  • 10 replies
  • 539 views
  • 0 likes
  • 3 in conversation