BookmarkSubscribeRSS Feed
🔒 This topic is solved and locked. Need further help from the community? Please sign in and ask a new question.
DavidPhillips2
Rhodochrosite | Level 12

Is there a good article on how to use Javascript inside of a SAS stored process?  I’ve been googling for it for a while.  I am using SAS 9.2.

1 ACCEPTED SOLUTION
2 REPLIES 2
RobertWoodruff
SAS Employee

Another way to think about using HTML5/Javascript with a SAS Stored Process is to create the HTML5/Javascript as separate assets and use the SP as a preprocessor. The SPs job is to read in the HTML5/Javascript, perform substitutions and send results to _Webout, (aka the browser )

A Stored Process that does just this is shown here, as represented in DI Studio


Capture.PNG
The “Serve page” transformation reads in the “Price manager portal.html” file, performs a bit of substitution and sends the results to _Webout. The SAS code looks like this:


%let _INFILE1_name =&_UnionP_Datamart_path/Web pages/Price manager portal.html;
data _null_;
file _webout;
infile "&_INFILE1_name" truncover;
input line $char2048.;
line = resolve(line); /* Macro substitution */
len = length(line);
put line varying2048. len;
run;

The .html file is created using web page design tool, in this case Microsoft’s Web Expressions. It also contains a Javascript section which was built using a Javascript tool, in this case JetBrains Webstorm. Inside the .html file special markers are placed which are substituted by the “Serve page” transformation. You can see an example in this snippet of html:


<h1 class="displayed">
    <table style="width: 100%">
        <tr>
            <td>
                <div class="iconTopDivClass">
                    <img alt="" src="http://&_WebServer:&_WebServerPort/UnionP_Pricing/Images/Modification.jpg" style="width:100%;height:100%;" />
                </div>
            </td>
            <td style="width: 100%">Price modification request<br>routed for
   approval</td>
        </tr>
    </table>
</h1>

SAS Innovate 2025: Call for Content

Are you ready for the spotlight? We're accepting content ideas for SAS Innovate 2025 to be held May 6-9 in Orlando, FL. The call is open until September 25. Read more here about why you should contribute and what is in it for you!

Submit your idea!

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.

Click image to register for webinarClick image to register for webinar

Classroom Training Available!

Select SAS Training centers are offering in-person courses. View upcoming courses for:

View all other training opportunities.

Discussion stats
  • 2 replies
  • 1636 views
  • 0 likes
  • 2 in conversation