BookmarkSubscribeRSS Feed
☑ This topic is solved. Need further help from the community? Please sign in and ask a new question.
Babloo
Rhodochrosite | Level 12
Is there any example or reference to the documents to access SAS datasets in HTML and CSS coding to fetch and display the value from SAS dataset to the prompts in web page?
1 ACCEPTED SOLUTION

Accepted Solutions
AhmedAl_Attar
Ammonite | Level 13

Hi @Babloo 

Let me first remind you of what I had told you few posts back!

Posted a month ago (112 views)  |   In reply to Babloo
@Babloo 

As a SAS skilled person working with SAS Viya 3.5, My preference would be
1. Use the Task Prompts
2. Optimize my SAS data sets for querying. 

The Task Prompts are more mature and provides lots of functionality out of the box (Stored Process Prompting Framework). It's shortens the development time.
But if you are a Web Stack Developer (Web, CSS, JS, Ajax) you may find the developing the HTML page more appealing, but you'll still need to interact with SAS skilled person, and someone who is familiar with how SAS Stored Processes used to work, as they are fundamentally provide the origin of the Task prompts.

Just my 2 cents

With that said, let me remind you, I'm not a JavaScript developer either, I'm familiar with it, but don't practice/use it.

 

But I'm familiar with Application Design principles and I can tell you,  you are going about this the wrong way!

You'll be much better off adopting MVC (Model-Viewer-Controller) App design paradigm for this quest of yours. Let me break it down for you

  • Viewer: JavaScript Function that controls which SAS back-end program to call, and which HTML drop-down Single/Multiple select widgets to populate with the returned JSON Response from the SAS Server
  • Model: SAS Program/Macro that knows about which data set(s) needs to used and how it needs to be manipulated/processed
  • Controller:  SAS back-end program that gets called by the Front-End Viewer, and figures out what to do based on the passed parameters to it, which Model to call/execute and generate the required JSON response in the required format

If all of the above is beyond/outside your skills set, then I would highly recommend you ask your management team to hire someone with those skills sets to help with achieving your projects objectives/goals.

 

That's all I can advise/help you with for now.

Good luck

 

 

 

 

 

 

 

 

 

 

 

 

 

View solution in original post

66 REPLIES 66
AhmedAl_Attar
Ammonite | Level 13

Hi @Babloo 

Need more info in order to help you out

  1. Do you have SAS Server deployment to access or just bunch of SAS data set?
  2. Do you have a Web Application that needs to display the Prompt values, or this is a Static HTML page? 

This kind of information is important in order to properly guide/assist you

Babloo
Rhodochrosite | Level 12
I'm building the static HTML web page. I have a bunch of SAS datasets.
Tom
Super User Tom
Super User

If you want to generate a static HTML file from a SAS dataset then just use a data step and the PUT statement.

Babloo
Rhodochrosite | Level 12
I think that you have misunderstood my question.

I'm writing the HTML code at the moment which will create static web page.

Few of the prompts (dropdown) depends on values from the SAS datasets and I
couldn't hard code it in my HTML code as there are numerous values.

How to access SAS datasets in HTML to receive values from SAS datasets?
Reeza
Super User

See this paper as a starting point.
https://support.sas.com/resources/papers/proceedings20/4260-2020.pdf

 

Video @ bottom of page

https://sasjs.io/

Babloo
Rhodochrosite | Level 12

@Reeza Any other references? Provided link is to build HTML app but I want to build the webpage using HTML code.

Kurt_Bremser
Super User

Instead of writing the HTML code, write SAS code which creates the HTML code.

filename htmlfile "path/to/your/file.html";

data _null_;
file htmlfile;
set sashelp.class end=done;
if _n_ = 1
then do;
  put '<html>';
  put '<head>';
  /* put additional header lines, as needed */
  put '</head>';
  put '<body>';
  put '<table>';
  put '<thead>';
  put '<tr>';
  put '<td>Name</td>';
  put '</tr>';
  put '</thead>';
  put '<tbody>';
end;
put '<tr>';
put '<td>' name '</td>';
put '</tr>';
if done
then do;
  put '</tbody>';
  put '</table>';
  put '</body>';
  put '</html>';
end;
run;
Babloo
Rhodochrosite | Level 12

@Kurt_Bremser  Good idea. Unfortunately, it's not helping me either. I executed your code just by chnaging the path and dataset name and all I got is below.

 

There were two observations and 2 variables in my dataset. Should I need to update the HTML code apart from path nad dataset name? Whether this HTML code tells how it is connected to SAS?

 

<html>
<head>
</head>
<body>
<table>
<thead>
<tr>
<td>Name</td>
</tr>
</thead>
<tbody>
<tr>
<td>. </td>
</tr>
<tr>
<td>. </td>
</tr>
</tbody>
</table>
</body>
</html>
Kurt_Bremser
Super User
You need to create the whole page in your SAS program, and use the method I showed to populate the prompt selection in the HTML form, instead of populating a table object.
Babloo
Rhodochrosite | Level 12

@Tom Webpage which I developing using HTML code has many prompts in which few prompts are supposed to take values from SAS datasets. 

 

Once I identified (with the help our community) the solution to access SAS tables in HTML, I want to incorporate it in my HTML code. I'm using SAS Viya to execute the SAS programs

Kurt_Bremser
Super User

Do you have a BI server, enabling you to use stored processes through a web interface, or do you just have a third-party web server, from which you could call SAS in batch mode?

Babloo
Rhodochrosite | Level 12
Currently I use SAS job execution server
and SAS Viya.

Not sure if this answers your question but this is what I know.
AhmedAl_Attar
Ammonite | Level 13

@Babloo 

PS: You would have saved us time and efforts if you had stated you have SAS Viya from the beginning

Look at this article Create a SAS Viya Job with a prompt using Task Prompts

 

Hope this helps

 

Babloo
Rhodochrosite | Level 12

@AhmedAl_Attar Thanks for the reference document. However I could not see that the provided link has reference to built HTML webpage using SAS.

sas-innovate-white.png

Register Today!

Join us for SAS Innovate 2025, our biggest and most exciting global event of the year, in Orlando, FL, from May 6-9.

 

Early bird rate extended! Save $200 when you sign up by March 31.

Register now!

How to Concatenate Values

Learn how use the CAT functions in SAS to join values from multiple variables into a single value.

Find more tutorials on the SAS Users YouTube channel.

SAS Training: Just a Click Away

 Ready to level-up your skills? Choose your own adventure.

Browse our catalog!

Discussion stats
  • 66 replies
  • 3865 views
  • 32 likes
  • 5 in conversation