Search code examples
streamsasproc

SAS proc stream : weird linebreaks


Server: Unix, Client: IE Edge Part of my code:

%let P_debug_log = %str(<INPUT TYPE='hidden' NAME='_DEBUG' VALUE='LOG'>);
proc stream outfile=_webout quoting=both resetdelim='_do' ASIS;
BEGIN
  %if "&_whattodo" ne "print" %then %do;
    <script language='JavaScript' type='text/javascript'>                                       
        function subForm(f,v) {
            if (v !== '') {
              $('#'+ f).append('<INPUT TYPE="hidden" NAME="'+ v +'" VALUE="1">');
            }
            $('#'+f).submit();       
          } 
      $(document).ready(function() {                                                            
        $('#footButtons').append($('.footButton'));   /* move all elements with class=footButton to pageFooter */
        $('#footMessage').append($('.footMsg'));   
        $('form.log').append("&P_debug_log.");
      });                                                                               
    </script>
  %end;
;;;;

Output: The Problem is, that generated stream Output has linebreaks "somewhere" but not where expected (with Option ASIS it should be formatted like in my code). This leads to unpredictable JavaScript Errors, e.g. when a linebreak is within a JavaScript string. It seems as if there is an implicit LRECL 1024. This would be OK if linebreaks would be set as expected. Any hints?

This is the originally formatted Output (Page Source):

     <script language='JavaScript' type='text/javascript'>                  function subForm(f,v) {         if (v !== '') {           $('#'+ f).append('<INPUT TYPE="hidden" NAME="'+ v +'" VALUE="1">');         }          $('#'+f).submit();             }
        $(document).ready(function() {                        $('#footButtons').append($('.footButton'));            $('#footMessage').append($('.footMsg'));            $('form.log').append("
<INPUT TYPE=
'hidden
' NAME=
'_DEBUG
' VALUE=
'LOG
'
>");       });                         </script>

Solution

  • Simply remove the ASIS option you have added to proc stream.

    I'm not sure if this is an undocumented feature but it doesn't appear in the documentation so I'm assuming so.

    http://documentation.sas.com/?docsetId=proc&docsetVersion=9.4&docsetTarget=n12zrkr08eiacmn17lcv4fmt79tb.htm&locale=en

    Once you remove that the weird line breaks disappear.

    Searching around, it appears the ASIS option is something to do with attempting to preserve column alignment.