Your SAS programs, embedded in web apps and elsewhere

Stored Procs w/JQuery

Reply
Super Contributor
Posts: 326

Stored Procs w/JQuery

Hi,

I'll be creating a web application using stored processes. Is it safe to use Jquery on my streaming html outputs?

Many thanks!
Milton
SAS Super FREQ
Posts: 304

Re: Stored Procs w/JQuery

If your intended use is to stream HTML containing jQuery code back to the browser, then you should be OK. I don't think it is any different than streaming HTML + JavaScript. A small test should confirm.

Vince DelGobbo
SAS R& D
Super Contributor
Posts: 326

Re: Stored Procs w/JQuery

Posted in reply to Vince_SAS
Thanks Vince, will give this one a try.

Regards,
Milton
Regular Contributor
Posts: 235

Re: Stored Procs w/JQuery

what did you created?

Im thinking about creating proc report which use a fixed header,sorting,.. actually something like the table-editor but better
Super Contributor
Posts: 326

Re: Stored Procs w/JQuery

Hi,

I haven't tried anything fancy yet. Just tested if I can use the jquery ui components with the streaming stored process.

Regards,
Milton
SAS Employee
Posts: 238

Stored Procs w/JQuery

Hi Milton,

Not sure if you have gotten this to work but wanted to chime in that I have built several examples using JavaScript within SAS Stored Processes.

Recent examples are a custom html form (built within the stp) that includes javascript functions to clear out special characters before submitting the process, another is a custom drop down box on the left side of a proc gchart.

Run it on the stored process server and be sure to leave the %STPBEGIN/%STPEND macros turned off.

~ Angela Hall

http://blogs.sas.com/content/bi

Super Contributor
Posts: 326

Re: Stored Procs w/JQuery

Posted in reply to AngelaHall

Hi Angela,

Thanks! Will check on your blog. I might get some more creative stuffs out there. Smiley Happy

I'm currently implementing and testing stp + jquery right now. I have 6 portlets, the values of the different fields on the 1st portlet controls all the results of the other 5 portlets. The submit button on the 1st portlet calls an ajax request which prepares the data for the other portlets before the content portion of the current page gets refreshed.

So far I'm getting what I am expecting. It's cool that sas could work in combination of html. Coding is just a little messy because of the put statements. :smileylaugh:

Milton

SAS Employee
Posts: 238

Stored Procs w/JQuery

Ah the put statements. I would actually recommend moving toward the cards4; input data lines capability.

Here is a great example - this avoids the quoting around java/js/etc and put statements.

http://support.sas.com/kb/37/050.html

Good luck!

~ Angela

Super Contributor
Posts: 326

Re: Stored Procs w/JQuery

Posted in reply to AngelaHall

WOW! I didn't know this! This surely will make the code more readable and neat!

Thanks again Angela for this great info.

Milton

Regular Contributor
Posts: 235

Stored Procs w/JQuery

Sounds very interesting, I would love to see the result and howto?

Super Contributor
Posts: 326

Stored Procs w/JQuery

Hi,

Will try to show the result after implementing this one. Smiley Happy

Regular Contributor
Posts: 235

Stored Procs w/JQuery

Hi there, i started with something basic. I was trying to get an autocomplete textbox but it does not work.

This is my code, when running the html as test.html it works...

data _null_;

  format infile $char1000.;

  input;

  infile = resolve(_infile_);

  file _webout;

  put infile;

cards4;

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"

                    "http://www.w3.org/TR/html4/loose.dtd">

<html>

<head>

  <script src="http://code.jquery.com/jquery-latest.js"></script>

  <link rel="stylesheet" href="http://dev.jquery.com/view/trunk/plugins/autocomplete/demo/main.css" type="text/css" />

  <link rel="stylesheet" href="http://dev.jquery.com/view/trunk/plugins/autocomplete/jquery.autocomplete.css" type="text/css" />

  <script type="text/javascript" src="http://dev.jquery.com/view/trunk/plugins/autocomplete/lib/jquery.bgiframe.min.js"></script>

  <script type="text/javascript" src="http://dev.jquery.com/view/trunk/plugins/autocomplete/lib/jquery.dimensions.js"></script>

  <script type="text/javascript" src="http://dev.jquery.com/view/trunk/plugins/autocomplete/jquery.autocomplete.js"></script>

  <script>

  $(document).ready(function(){

    var data = "Core Selectors Attributes Traversing Manipulation CSS Events Effects Ajax Utilities".split(" ");

$("#example").autocomplete(data);

  });

  </script>

  <title> Test </title

</head>

<body>

  API Reference: <input id="example" /> (try "C" or "E")

</body>

</html>

thanks!!!!

;;;;

run;

Super Contributor
Posts: 326

Stored Procs w/JQuery

Hi,

I actually tried your code above and got the same result.

So instead of referencing the js file on their site like this...

<script type="text/javascript" src="http://dev.jquery.com/view/trunk/plugins/autocomplete/jquery.autocomplete.js"></script>

Try downloading the js and css files and put it somewhere your server so you can access it like this...

<script type="text/javascript" src="http://sasserver:8080/Portal/scripts/jquery.autocomplete.js"></script>

or even create a different war file to place your jquery files

<script type="text/javascript" src="http://sasserver:8080/MyCustom/scripts/jquery.autocomplete.js"></script>

Hope this helps.

Milton

Regular Contributor
Posts: 235

Re: Stored Procs w/JQuery

Milts

Thanks but i dont have any idea how i can put files on my sasserver like that? Is it via management console?

Im really waiting for your examples with Jquery Smiley Happy

greets

Super Contributor
Posts: 326

Stored Procs w/JQuery

Hi Filip

Sorry for the late reply.

If you are using Tomcat here's an example of steps you can do:

1. on your tomcat webapps directory (ex. C:\<tomcat version>\webapps), copy SASTheme_default(since it's the simplest out there) and rename it whichever name you like (ex. SASCustom)

2. Delete the contents of SASCustom except for the META-INF and WEB-INF folders.

3. Add new folders on SASCustom (ex. scripts, styles).

4. Add files that you'll want to be accessed by your stored procs (ex. put your jquery scripts inside SASCustom\scripts-)

5. Restart Tomcat

6. Open a browser and try to check if you can access http://<servername>:8080/SASCustom/scripts/jquery.js. If it prompts you to open or download the file, then you've correctly done the steps above.

7. Try your jquery explorations. Actually I only used jquery to simplify access(instead of using getelementbyid most of the time because it's so looooong) and for the ajax function(i'm not confident using ajax if I'll be coding the function myself haha!). What you're trying to actually explore like your testing above is more advanced. Enjoy! Smiley Happy

However, if you're using Weblogic or WebSphere, there are a few more steps and I'm not much familiar about it but it's still similar to the example I gave above.

Hope this helps.

Milton

Ask a Question
Discussion stats
  • 22 replies
  • 2145 views
  • 3 likes
  • 5 in conversation