SyntaxHighlighter

Tuesday, January 24, 2012

It varies



If I extract source code from a SAS catalog entry of type source, all the lines are padded with spaces to the LRECL value which defaults to 128. Therefore, when you copy and paste the source code to print it, the lines come out as double spaced due to the line length.

This is where the $VARYING. format comes into play. In the below code, the input file is read in as $CHAR256. to retain the leading spaces then the line LENGTH() is determined after trailing spaces have been removed with the TRIM() function. That line length value (len) is added to the $VARYING. format which will now keep my leading spaces or indentation and remove the trailing spaces.

The CLIPBRD (clipboard) access method is used so that the contents are written to the computer's clipboard so that the trimmed contents can be pasted to whatever destination you desire.

filename xin catalog "lib.cat.entry.source" ;
filename xout clipbrd ;
data _null_ ;
  infile xin ;
  file xout ;
  input line $char256. ;
  len = length( trim( line ) ) ;
  put line $varying256. len ;
run ;
filename xin clear ;
filename xout clear ;

Thursday, January 5, 2012

What remote libnames are assigned?


I was attempting to upload some SAS formats from my local PC to the SAS server and while there was no error message in the log, the formats did not get updated. I had assumed the APFMTLIB was already assigned but it was not and the way I determined that was via the following code.

signon ;
  rsubmit wait = yes ;

    proc sql ;
      create table onserver as
        select   libname
               , path
          from   dictionary.libnames ;
    quit ;

    proc download
      data = onserver
      out  = localdsn ;
    run ;

  endrsubmit ;
signoff ;