Stored Process generates HTML Some excerpts… <form method="get" action="http://khv-sas-iis2.cfsi.local/SASStoredProcess/do?" target ="content"> < select name=" _program "> <option value="/Shared Data/SASTesting/cabotCollectionsDashboard">Month to Date</option> <option value="/Shared Data/SASTesting/ccDashDaily">Daily</option> <option value="/Shared Data/SASTesting/ccDashYTD">Year to Date</option> </select> <input type="checkbox" name="_debug" value="log">Show log<nbsp><nbsp><nbsp> <input type="checkbox" name="_debug" value="time">Show time taken<nbsp> <input type="checkbox" name="inline" value="1">Inline?<nbsp> <input type="submit" value="Run"><br>
More excerpts of HTML organisationName <select name=" organisationName " onchange="this.form.submit(); "> <option value="Cabot Debt Purchase " selected >Cabot Debt Purchase </option> <option value="Cabot Stratford Serviced ">Cabot Stratford Serviced </option> </select> </form> <iframe name="content" height="85%" width="100%" > </iframe> </body> </html>
Use JavaScript Libraries
A few good JavaScript libraries jQuery Write less, do more HandsOnTable or EasyUI Excel-like spreadsheet for Apps HighCharts Create interactive web charts easily D3 Data Driven Documents
Manipulating your web page jQuery makes it easy to select parts of your page and attach functionality $(document).ready(function(){ <script> $("button").click(function(){ $(document).ready(function(){ $("p").hide(); $("button").click(function(){ }); $("#div1").load("demo_test.txt"); }); }); }); </script> $(document).ready(function(){ $("button").click(function(){ <div id=“div1"> $("#div1").fadeIn(); <h2>Let jQuery AJAX Change This Text</h2> $("#div2").fadeIn("slow"); </div> $("#div3").fadeIn(3000); }); <button>Get External Content</button> });
Making a better table in web browsers
Making interactive charts
Creating Data Driven Documents
Hosted Libraries You can download JavaScript libraries and keep on your site Or you can use a Hosted Library, such as Google’s read about it here https://developers.google.com/speed/libraries/ <script src=“https://ajax.googleapis.com/ajax/libs/jquery/2.1.4/ jquery.min.js”></script> Some host their own library <script src=“http://d3js.org/d3.v3.min.js"> </script> <script src="http://code.highcharts.com/highcharts.js"> </script>
How to use SAS with JavaScript objects HTML 5 structures your page CSS 3 controls the look and feel JavaScript handles the interactivity Data typically either hard-coded or provided in JSON, CSV, TSV, … SAS Stored Processes Provide the data in CSV or JSON format using data steps or PROC JSON Create and customise the HTML, CSS & JavaScript Using data steps or PROC STREAM
Use JSON with Stored Processes
What is JSON and why use it? Key-Value pairs Man and Machine readable Nested if necessary Used by many JavaScript objects Is a subset of JavaScript Object Notation, which is how objects in JavaScript are built Sometimes XML or CSV can be used Very flexible can represent complex nested hierarchies of data
Example { "name": "Phil Mason", "home": { "town": "Wallingford", "phone": 1491824891, "current home": true, "ages": [ 51, 46, 18, 16, 13 ] } }
Data Step to produce JSON Can run from a stored process Write to _webout to stream to browser Can define macros, to make it flexible and easy to repeat Can handle very complex & nested JSON
Example data step making JSON data _null_ ; set sashelp.class end=_end ; if _n_=1 then put '[' ; put '{' ; put '"Name":"' name +(-1) '",' ; put '"Sex":"' sex +(-1) '",' ; put '"Age":"' age +(-1) '",' ; put '"Height":"' height +(-1) '",' ; put '"Weight":"' weight +(-1) '"' ; put '}' ; if not _end then put ',' ; else put ']' ; run ;
[ { "Name":"Alfred", "Sex":"M", "Age":"14", "Height":"69", "Weight":"112.5" } , { "Name":"Alice", "Sex":"F", "Age":"13", "Height":"56.5",
PROC JSON SAS 9.4 Easily produces JSON from SAS datasets Can produce more complex JSON as well as simple JSON Can use macros to write PROC JSON, making it very flexible
PROC JSON { "SASJSONExport": "1.0", Minimum code needed "SASTableData+CLASS": [ { Produces default output "Name": "Alfred", "Sex": "M", "Age": 14, "Height": 69, "Weight": 112.5 }, { proc json out=temp ; "Name": "Alice", export sashelp.class ; "Sex": " F", run ; "Age": 13, "Height": 56.5, "Weight": 84 },
Better PROC JSON code Pretty - lays out the JSON clearly noSAStags - leaves out SAS metadata from the JSON proc json out='/tmp/class.json' pretty nosastags ; export sashelp.class ; run ; [ { "Name": "Alfred", "Sex": "M", Produces this output "Age": 14, "Height": 69, "Weight": 112.5 },
JavaScript libraries with SAS
Recommend
More recommend