Help using Base SAS procedures

SAS Batch CMD Limit

Occasional Contributor
Posts: 5

SAS Batch CMD Limit

We currently run a number of SAS jobs by launching a .bat file. Now i am aware there is a limit on the characters when submitting via batch:


  • Submitting a SAS program via a batch file imposes a maximum length limit of 256 characters prior to SAS 9.2. For SAS 9.2 and beyond you can use the new SAS system option of LRECL= to specify a range of 1-32767 to use for reading and writing external files. The default for the LRECL= system option is 256. This option is valid in the configuration file, at SAS invocation, the OPTIONS statement, or the SAS Systems Option window. Under z/OS, the LRECL= system option is recognized only for reading and writing HFS files.


Now i assumed I could use this option per:


However it will not work, when it accepts the option for LRECL it ignores the specification of the LOG and PRINT locations and goes to the default instead. I am using Powershell to initial SAS which works fine until now that i have added additional characters which pushed it over its limit can anoyone see what is wrong?



$CMD = "C:\Program Files\SAS\SASFoundation\9.2\sas.exe"
$batch = "-batch"
$lrecl = "-lrecl"
$lrcelconfig = "1000"
$sysparm = "-sysparm"
$sysparmcode = ((Get-Date).ToString('ddMMMyy:HH:mm:ss'))
$config = "-CONFIG"
$configfile = "C:\Program Files\SAS\SASFoundation\9.2\nls\en\SASV9_SCHEDULER.CFG"
$sysin = "-SYSIN"
$sysinfile = "\\xxxxxxxxxxx\xxxx\xxxxxxxxxxxxxxx\xxxxxxxxx\xxxx\xxxxx\code\"
$print = "-PRINT"
$printfile = "\\xxxxxxxxxxx\xxxx\xxxxxxxxxxxxxxx\xxxxxxxxx\xxxx\xxxxx\log\sy_ct_main_v1_$((Get-Date).ToString('yyyyMMdd_HHmm')).lst"
$log = "-LOG"
$logfile = "\\xxxxxxxxxxx\xxxx\xxxxxxxxxxxxxxx\xxxxxxxxx\xxxx\xxxxx\log\sy_ct_main_v1_$((Get-Date).ToString('yyyyMMdd_HHmm')).log"

& $CMD $batch $lrecl $lrcelconfig $sysparm $sysparmcode $config $configfile $sysin $sysinfile $print $printfile $log $logfile


Running: SAS 9.2 TS2M3


When i Run the above SAS runs but for some reason it is ignoring the Print and the Log Locations, however if remove the lrecl option it says you have to specifiy the log location which i know is the error where it has run out of space on the command.



Valued Guide
Posts: 2,191

Re: SAS Batch CMD Limit

You could place all these parameters into a config file in a folder reserved for this job - and only these parameters.
Change the .bat file to start with a CD command changing the current folder to the one with that special sasv9.cfg
After that you need no parameters when invoking SAS
They all come from that job-specific config file.
There is a past conference paper on this
472-2013: Configure Your Foundation SAS® Client Easily and without Risk
Super User
Posts: 10,283

Re: SAS Batch CMD Limit

The LRECL= commandline option of SAS does not affect the length of the commandline, it affects the length limit for external files (like your .sas, .log and .lst files). The length of the commandline is a limit set by the operating system.


The real reason for your problems might not be SAS at all:


Windows imposes a limit on the length of absolute pathnames (this also means fully qualified filenames) which is 260 bytes.

Similar limits exist in other OS's and the respective file system drivers (jfs, ufs, ext3/ext4 and so on all have a limit of 255 characters)


Try to reduce complexity. At the start of the script, cd to a directory from where you have short, simple shortcuts to your program, log, print and config file locations. From there, use relative paths.


Or reduce your path length overall. Just imagining having to type such monstrosities makes me cringe.

Maxims of Maximally Efficient SAS Programmers
How to convert datasets to data steps
How to post code
Ask a Question
Discussion stats
  • 2 replies
  • 3 in conversation