<?xml version="1.0" encoding="UTF-8"?>
<rss xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" xmlns:taxo="http://purl.org/rss/1.0/modules/taxonomy/" version="2.0">
  <channel>
    <title>topic Re: Stored processes HTML Javascript in Developers</title>
    <link>https://communities.sas.com/t5/Developers/Stored-processes-HTML-Javascript/m-p/265804#M4936</link>
    <description>&lt;P&gt;When you call a stored process via the SASStoredProcess URL, the macro variables defined as stored process parameters are included in the URL. Passing complete SAS steps will probably scramble your URLs, and executing code from the URL will be a severe security risk.&lt;/P&gt;
&lt;P&gt;Instead I would define one simple parameter which then is used in the stored process to decide which branch to follow.&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Eg:&lt;/P&gt;
&lt;P&gt;&amp;lt;empty&amp;gt; display empty form&lt;/P&gt;
&lt;P&gt;1 search for records&lt;/P&gt;
&lt;P&gt;2 add records&lt;/P&gt;
&lt;P&gt;3 delete records&lt;/P&gt;
&lt;P&gt;and so on&lt;/P&gt;
&lt;P&gt;Keep your stored process parameters as simple as possible, so your URLs stay human-readable and don't cause errors or security problems (by displaying sensitive data or allowing code injection)&lt;/P&gt;</description>
    <pubDate>Sat, 23 Apr 2016 05:49:36 GMT</pubDate>
    <dc:creator>Kurt_Bremser</dc:creator>
    <dc:date>2016-04-23T05:49:36Z</dc:date>
    <item>
      <title>Stored processes HTML Javascript</title>
      <link>https://communities.sas.com/t5/Developers/Stored-processes-HTML-Javascript/m-p/265754#M4935</link>
      <description>&lt;P&gt;My SAS is weak and my javascript is remedial at best&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;I would like to:&lt;/P&gt;
&lt;P&gt;1) From a javascript function found in a Macro of a Stored Procedure&lt;/P&gt;
&lt;P&gt;&amp;nbsp;a) pass variables to a global variable&lt;/P&gt;
&lt;P&gt;&amp;nbsp;b) run a macro found in the same stored procedure&lt;/P&gt;
&lt;P&gt;&amp;nbsp;c) populate variable values from the Macro back into the javascript function that called the Macro&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;I hope to not use HTML submit to perform data interaction&lt;/P&gt;
&lt;P&gt;** my obs are many and each obs have over 12 culumns&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;Once&amp;nbsp;the concept is prooven&amp;nbsp;I hope to use the same method to append and update the sas data set.&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Below is a snippet what I've been working on that is incomplete in many ways&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;%global&amp;nbsp; provs mrncnt mrns;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;%macro prepdata;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;%let mrn =&lt;BR /&gt;(proc sql&lt;BR /&gt;Select MRN from data_src&lt;BR /&gt;where prov_name =&amp;amp;prov&lt;BR /&gt;Run;&lt;/P&gt;
&lt;P&gt;)&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;%let mrncnt= &lt;BR /&gt;(proc sql&lt;BR /&gt;Select count(mrn) from data_src&lt;BR /&gt;where prov_name =&amp;amp;prov&lt;BR /&gt;Run;&lt;/P&gt;
&lt;P&gt;)&lt;BR /&gt;%mend prepdata;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;%Macro openfrm;&lt;BR /&gt;data _null_;&lt;BR /&gt;file _webout;&lt;/P&gt;
&lt;P&gt;thissrv = symget('_url');&lt;BR /&gt;thispgm = symget('_program');&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;put '&amp;lt;!DOCTYPE html&amp;gt;';&lt;BR /&gt;put '&amp;lt;HTML&amp;gt;';&lt;BR /&gt;put '&amp;lt;head&amp;gt;';&lt;BR /&gt;put '&amp;lt;style&amp;gt;';&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;put "th, td, input {";&lt;BR /&gt;put "text-align: center;";&lt;BR /&gt;put "text-wrap:unrestricted;";&lt;BR /&gt;put "}";&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;put "TEXTAREA[READONLY]{";&lt;BR /&gt;put "BORDER:hidden;";&lt;BR /&gt;put "background-color:#FFFFFF;";&lt;BR /&gt;put "color:#000000;";&lt;BR /&gt;put "}"&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;put '&amp;lt;/style&amp;gt;';&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;put '&amp;lt;script type="text/javascript" language="JavaScript"&amp;gt;';&lt;/P&gt;
&lt;P&gt;put 'function pasvar(){';&lt;BR /&gt;put 'var aprov =document.getElementById("Prov")';&lt;BR /&gt;put 'var ' &amp;amp;provs ' = aprov.options[aprov.selectedIndex].text';&lt;BR /&gt;???&amp;nbsp; call the macro prepdata ????&lt;BR /&gt;put "openadd('1st',"&lt;BR /&gt;&amp;nbsp;&amp;amp;mrncnt")';&lt;BR /&gt;put "}";&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;put 'var nm=0;';&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;put 'function openadd(a,b){';&lt;BR /&gt;PUT "if(nm&amp;lt;0){nm=0}for( i=1; i&amp;lt;1+b; i++){nm = i;add(a,i);}";&lt;BR /&gt;PUT "}";&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;put "function add(el,rw){";&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;put "targEl=document.getElementById(el);";&lt;BR /&gt;Put 'tbody = targEl.getElementsByTagName("tbody")[0];';&lt;/P&gt;
&lt;P&gt;put 'row = document.createElement("TR");';&lt;/P&gt;
&lt;P&gt;put 'cell1 = document.createElement("TD");';&lt;BR /&gt;put 'inp1 = document.createElement("INPUT");';&lt;BR /&gt;put 'inp1.setAttribute( "type","text");';&lt;BR /&gt;put 'inp1.setAttribute( "name","line");';&lt;BR /&gt;put 'inp1.setAttribute( "id","line_" +nm);';&lt;BR /&gt;put 'inp1.setAttribute( "value", nm);';&lt;BR /&gt;put 'inp1.setAttribute( "size","3");';&lt;BR /&gt;put 'inp1.setAttribute( "disabled",true);';&lt;BR /&gt;put 'inp1.setAttribute( "style","border:none");';&lt;BR /&gt;put "cell1.appendChild(inp3);";&lt;/P&gt;
&lt;P&gt;put "row.appendChild(cell3);";&lt;BR /&gt;put "tbody.appendChild(row);";&lt;/P&gt;
&lt;P&gt;put "}";&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;put '&amp;lt;/SCRIPT&amp;gt;';&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;put '&amp;lt;/HEAD&amp;gt;';&lt;/P&gt;
&lt;P&gt;put '&amp;lt;BODY&amp;gt;';&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;put '&amp;lt;FORM ACTION="&lt;BR /&gt;&amp;nbsp;'&amp;nbsp; thissrv +(-1) '" method=post&amp;gt;';&lt;BR /&gt;put '&amp;lt;input type="hidden" name="_program" value="&lt;BR /&gt;&amp;nbsp;' thispgm +(-1) '"&amp;gt;';&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;put '&amp;lt;INPUT TYPE="HIDDEN" NAME="reqtype" VALUE="add"&amp;gt;';&lt;BR /&gt;put '&amp;lt;table bgcolor="#3399FF"&amp;gt;';&lt;BR /&gt;put '&amp;lt;tr&amp;gt;';&lt;BR /&gt;put '&amp;lt;th&amp;gt;';&lt;BR /&gt;put '&amp;lt;table align="LEFT" border="0" cellspacing="0" bgcolor="#FFFFFF" &amp;gt;';&lt;BR /&gt;put '&amp;lt;tr&amp;gt;';&lt;BR /&gt;put '&amp;lt;th&amp;gt;Provider:&amp;lt;/th&amp;gt;';&lt;BR /&gt;put '&amp;lt;/tr&amp;gt;';&lt;/P&gt;
&lt;P&gt;put '&amp;lt;/tr&amp;gt;';&lt;/P&gt;
&lt;P&gt;put '&amp;lt;/table&amp;gt;';&lt;/P&gt;
&lt;P&gt;put '&amp;lt;/th&amp;gt;';&lt;/P&gt;
&lt;P&gt;put '&amp;lt;/tr&amp;gt;';&lt;/P&gt;
&lt;P&gt;put '&amp;lt;/table&amp;gt;';&lt;/P&gt;
&lt;P&gt;put '&amp;lt;table id= "1st" border="0" cellspacing="0" bgcolor="#FFFFFF" &amp;gt;';&lt;/P&gt;
&lt;P&gt;put '&amp;lt;tbody&amp;gt;';&lt;/P&gt;
&lt;P&gt;put '&amp;lt;tr name = "row1" &amp;gt;';&lt;/P&gt;
&lt;P&gt;put '&amp;lt;TD&amp;gt;&amp;lt;input type="text" name="line_i" id="line_i" size="3" value ="#" READONLY="READONLY" tabindex="-1"&amp;gt;&amp;lt;/TD&amp;gt;';&lt;/P&gt;
&lt;P&gt;put '&amp;lt;/tr&amp;gt;';&lt;/P&gt;
&lt;P&gt;　&lt;/P&gt;
&lt;P&gt;put '&amp;lt;/tbody&amp;gt;';&lt;/P&gt;
&lt;P&gt;put '&amp;lt;/table&amp;gt;';&lt;/P&gt;
&lt;P&gt;&lt;BR /&gt;put '&amp;lt;/table&amp;gt;';&lt;BR /&gt;put '&amp;lt;/body&amp;gt;';&lt;/P&gt;
&lt;P&gt;&lt;BR /&gt;put '&amp;lt;/html&amp;gt;';&lt;/P&gt;
&lt;P&gt;Run;&lt;BR /&gt;%mend openfrm;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Thak you in advance&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Fri, 22 Apr 2016 19:27:25 GMT</pubDate>
      <guid>https://communities.sas.com/t5/Developers/Stored-processes-HTML-Javascript/m-p/265754#M4935</guid>
      <dc:creator>TimMandell</dc:creator>
      <dc:date>2016-04-22T19:27:25Z</dc:date>
    </item>
    <item>
      <title>Re: Stored processes HTML Javascript</title>
      <link>https://communities.sas.com/t5/Developers/Stored-processes-HTML-Javascript/m-p/265804#M4936</link>
      <description>&lt;P&gt;When you call a stored process via the SASStoredProcess URL, the macro variables defined as stored process parameters are included in the URL. Passing complete SAS steps will probably scramble your URLs, and executing code from the URL will be a severe security risk.&lt;/P&gt;
&lt;P&gt;Instead I would define one simple parameter which then is used in the stored process to decide which branch to follow.&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Eg:&lt;/P&gt;
&lt;P&gt;&amp;lt;empty&amp;gt; display empty form&lt;/P&gt;
&lt;P&gt;1 search for records&lt;/P&gt;
&lt;P&gt;2 add records&lt;/P&gt;
&lt;P&gt;3 delete records&lt;/P&gt;
&lt;P&gt;and so on&lt;/P&gt;
&lt;P&gt;Keep your stored process parameters as simple as possible, so your URLs stay human-readable and don't cause errors or security problems (by displaying sensitive data or allowing code injection)&lt;/P&gt;</description>
      <pubDate>Sat, 23 Apr 2016 05:49:36 GMT</pubDate>
      <guid>https://communities.sas.com/t5/Developers/Stored-processes-HTML-Javascript/m-p/265804#M4936</guid>
      <dc:creator>Kurt_Bremser</dc:creator>
      <dc:date>2016-04-23T05:49:36Z</dc:date>
    </item>
    <item>
      <title>Re: Stored processes HTML Javascript</title>
      <link>https://communities.sas.com/t5/Developers/Stored-processes-HTML-Javascript/m-p/266086#M4937</link>
      <description>&lt;P&gt;I agree.&amp;nbsp; That is why I want to keep the entire&amp;nbsp;SP together in one program.&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;If possible, it seems best to call macros from within the stored process via javascript funtions&amp;nbsp;and also use javascript functions&amp;nbsp;to pass variables between the macros.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;This should keep all data out of the URL.&lt;/P&gt;</description>
      <pubDate>Mon, 25 Apr 2016 15:40:14 GMT</pubDate>
      <guid>https://communities.sas.com/t5/Developers/Stored-processes-HTML-Javascript/m-p/266086#M4937</guid>
      <dc:creator>TimMandell</dc:creator>
      <dc:date>2016-04-25T15:40:14Z</dc:date>
    </item>
    <item>
      <title>Re: Stored processes HTML Javascript</title>
      <link>https://communities.sas.com/t5/Developers/Stored-processes-HTML-Javascript/m-p/266221#M4938</link>
      <description>&lt;P&gt;Hi Tim,&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Please don't take this the wrong way, but there are a few&amp;nbsp;really bad practices with what you're trying to do here, from both a SAS and web application programming perspective.&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;In any case, here are my 2 cents:&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;1) If you absolutely have to use SAS to serve your static HTML/JS content, you're better off storing your .html code in a static file and outputting it from your macro like this:&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;  data _null_;
    infile myStaticCodeStoredSomewhere.html;
    file _webout;
    put _infile_;
  run;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;This will work fine as you have no variables in your html, and it will make it considerably easier to edit.&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;2) If you use HTTP POST to submit your data you will be able to pass your code in as part of the body of the request and no variables will be visible in the URL, if that's what you're concerned about. Unless your deployment is properly secured with TLS then this is just security through obscurity.&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;What exactly are you trying to do here, what's the bigger picture? Build some kind of cascaded filter? Edit rows of data?&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;What version of SAS are you running? What's your level of Javascript experience? Is this Javascript your own code?&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Nik&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Mon, 25 Apr 2016 21:09:35 GMT</pubDate>
      <guid>https://communities.sas.com/t5/Developers/Stored-processes-HTML-Javascript/m-p/266221#M4938</guid>
      <dc:creator>boemskats</dc:creator>
      <dc:date>2016-04-25T21:09:35Z</dc:date>
    </item>
    <item>
      <title>Re: Stored processes HTML Javascript</title>
      <link>https://communities.sas.com/t5/Developers/Stored-processes-HTML-Javascript/m-p/266361#M4939</link>
      <description>&lt;P&gt;About the setup:&lt;/P&gt;
&lt;P&gt;There is&amp;nbsp;no access to a&amp;nbsp; web server only the SAS 9.4 Stored Process web portal.&amp;nbsp; This seems powerful and secure enough for our purpose.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Concept:&lt;/P&gt;
&lt;P&gt;We are working to bring data into a form based on filterd values.&amp;nbsp; Interact with it (edit fields) Add additional observation lines.&lt;/P&gt;
&lt;P&gt;Then submit the data back into the host table updating the edited fields and appending the additional lines of observations.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Code: I've typed up the code&amp;nbsp;and the supporting&amp;nbsp;concepts are learned recently&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Looking at excepts of “&lt;STRONG&gt;SAS Server Pages: Generating Dynamic Content&lt;/STRONG&gt;”&amp;nbsp; from Don Henderson (who I had the pleasure of meeting),&amp;nbsp;it's uncertain that&amp;nbsp;calling a Macro and passing variables&amp;nbsp;from Javascript without using submit can be accomplished.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Tue, 26 Apr 2016 13:36:28 GMT</pubDate>
      <guid>https://communities.sas.com/t5/Developers/Stored-processes-HTML-Javascript/m-p/266361#M4939</guid>
      <dc:creator>TimMandell</dc:creator>
      <dc:date>2016-04-26T13:36:28Z</dc:date>
    </item>
  </channel>
</rss>

