Introduction

This page was created as a vehicle for showing how statistical and mathematical software can be used from the command line in Windows. This means we can also put the command line into a batch file and then run it from Windows Explorer. It is therefore especially useful for blind users who rely on screen reader software to have access to printed text and often cannot use this software interactively. Most of the experiences listed here are my own, but I am grateful to other people (both blind and sighted) who have shared their experiences with me over the years.

Please contact Jonathan Godfrey if you wish to ask questions about software not listed here that I might know something about or for more detail than is given here. Sharing your personal experiences with me might also help improve this page.

Software is listed in alphabetical order and currently includes:

I plan to fill in the section for Matlab at some stage. I don’t have all software listed here on all of my computers so must wait until I get time at work.

General comments

For each of the software applications I have tested, I start by specifying the version of the software used and the date I last checked things were working. This has proven important as some software changes the folder in which it is installed. This will have particular importance for the command line you will use.

Three subsections are then given:

The text of these subsections is separated by headings so you can be sure where the files start and stop.

Any additional notes that might help are in a final subsection.

I’ve presented the full command line here because I don’t edit my system’s path variable unless software does it as part of its installation. I know I could, but I prefer to use more advanced methods in my own work that are not appropriate for sharing here. If you do choose to edit your path, then the full path to the executable in the command lines is not required.

Mathematica

Version 10 was tested on 20 September 2016. My thanks to Theodor Loots (University of Pretoria) who provided most of the content for this example.

Command line

"C:\Program Files\Wolfram Research\Mathematica\10.0\math.exe" -script Input.txt

Input file content

MyFile = OpenWrite["output.tex"]
OutputFile = OpenWrite["log.txt"]
$Messages = {OutputFile}
SetOptions[MyFile, FormatType -> OutputForm]; SetOptions[OutputFile, FormatType -> InputForm];

F[x] := x^2+1;
Write[MyFile, TeXForm[F[x]]];

Sol = Integrate[F[x], x]
Write[MyFile, TeXForm[Sol]];

Quit[]

Output file content (output.tex)

The integral of $x^2+1$ is
$$\frac{x^3}{3}+x$$

Notes

The file log.txt was also generated but is blank for this example input file.

Matlab

Command line

c:\prog

Input file content

blah

Output file content

blah

Notes

Maxima

Version 5.25.0 tested on 16 September 2016

Command line

"C:\Program Files\Maxima-5.25.0\bin\maxima.bat" -q --userdir="." < "Input.txt" > Output.txt

Input file content

display2d:false;
diff(2*x+3,x,1);
diff(t1*exp(-t2*exp(-t3*x)),x,1);
tex(%o3);
solve(a*x^2+b*x+c=0,x); 
tex(solve(a*x^2+b*x+c=0,x)); 

Output file content

(%i1) 
(%o1) false
(%i2) 
(%o2) 2
(%i3) 
(%o3) t1*t2*t3*%e^(-t2*%e^-(t3*x)-t3*x)
(%i4) $${\it t_1}\,{\it t_2}\,{\it t_3}\,e^{-{\it t_2}\,e^ {- {\it t_3}\,x
  }-{\it t_3}\,x}\leqno{\tt (\%o3)}$$
(%o4) "(\\%o3)"
(%i5) 
(%o5) [x = -(sqrt(b^2-4*a*c)+b)/(2*a),x = (sqrt(b^2-4*a*c)-b)/(2*a)]
$$\left[ x=-{{\sqrt{b^2-4\,a\,c}+b}\over{2\,a}} , x={{\sqrt{b^2-4\,a
 \,c}-b}\over{2\,a}} \right] $$
(%o6) false
(%i7) 

Notes

The first line of the Input.txt file helps display content in a more readable form. This is more useful for interactive use of wxMaxima than the batch processing mode of operation.

Minitab

Minitab 17 was tested in October 2016 and was a complete failure. See the notes section below for more detail, but this software is not recommended for use in batch mode at the time of writing, nor is it recommended for use by blind people in an interactive mode.

Command line

"C:\Program Files\Minitab\Minitab 17\mtb.exe" "E:\Input.mtb"

Notes

  • Minitab 16 could be forced to show the commands used for obtaining desired output; I could not get this to be shown in Minitab 17 so I could not find out what commands were needed to complete various tasks.
  • Some commands have been changed or updated and the documentation found online for Minitab 16 or older versions was unhelpful.

Octave

Version 4.0.0 tested on 16 September 2016

Command line

"C:\Octave\Octave-4.0.0\bin\octave-cli" -q Input.m

Input file content(Input files are traditionally given the single letter m for an extension)

diary Output.txt
Mat=[5,2;-1,5]
RHS=[16, 13]'
Sol=Mat\RHS
diary off

Output file content

Mat =

   5   2
  -1   5

RHS =

   16
   13

Sol =

   2.0000
   3.0000

Notes

  1. Watch that you delete the diary (Output) file before processing the input file, because the default behaviour is to append output to it.
  2. You can suppress output for obvious results by adding a semicolon at the end of any Octave command.

R

Version 3.6.1 tested on 18 September 2019

Command line

C:\PROGRA~1\R\R-36~1.1\bin\R.exe CMD BATCH --vanilla --quiet Input.R

Input file content (Input.R)

MySample=sample(40,10)
MySample
mean(MySample)

Output file content (automatically called Input.Rout)

> MySample=sample(40,10)
> MySample
 [1] 30 15 14  4 21 19 12  2 20 29
> mean(MySample)
[1] 16.6
> 
> proc.time()
   user  system elapsed 
   0.15    0.04    0.34 

Notes

  1. The path used in the command line is in compact form. If you change it to match your full path, you will need to quote the full path.
  2. The vanilla and quiet options help by ensuring a blank workspace and minimises the output by suppressing the welcome messages respectively.
  3. The input filename is used for the output filename with the modified extension. I’ve used Input.R here for reasons of consistency only. I usually use much more informative filenames for my R scripts.
  4. If you have installed the BrailleR package, then you will be able to create the necessary batch file with the right command line using the MakeBatch() command. For example, if you have the input file Input.R then you can issue the command MakeBatch("Input.R") and this will create a new batch file for you called Input.bat.

SAS

Version 9.4 was tested using a laboratory computer on 22 September 2016. The Input file was saved on a memory stick, so the command line was run from the folder on the memory stick, not on a hard drive folder.

Command line

"C:\Program Files\SASHome\SASFoundation\9.4\SAS.exe" -sysin "Input.sas" -nosplash -icon -log "log.txt" -print "Output.txt"

Input file content (Input.sas)

%let MyPath = .;

ods graphics on/imagename="OurGraph";

proc import datafile="&MyPath.\DataFile.csv"
out=OurData
dbms=csv
replace;
getnames=yes;
run;

proc univariate data=OurData; run;

proc reg data=OurData simple
outest=OurModel(keep=Intercept X)
plots(only stats=none)=(FitPlot(nolimits));
model y = x;
run;
quit;

Output file content (log.txt)

1                                       The SAS System       11:04 Thursday, September 22, 2016

NOTE: Copyright (c) 2002-2012 by SAS Institute Inc., Cary, NC, USA. 
NOTE: SAS (r) Proprietary Software 9.4 (TS1M2) 
      Licensed to MASSEY UNIVERSITY - EAS, Site 10004572.
NOTE: This session is executing on the X64_7PRO  platform.



NOTE: Updated analytical products:
      
      SAS/STAT 13.2
      SAS/ETS 13.2
      SAS/OR 13.2
      SAS/IML 13.2
      SAS/QC 13.2

NOTE: Additional host information:

 X64_7PRO WIN 6.1.7601 Service Pack 1 Workstation

NOTE: SAS initialization used:
      real time           0.27 seconds
      cpu time            0.18 seconds
      
1          %let MyPath = .;
2          
3          ods graphics on/imagename="OurGraph";
4          
5          proc import datafile="&MyPath.\DataFile.csv"
6          out=OurData
7          dbms=csv
8          replace;
9          getnames=yes;
10         run;

11          /**********************************************************************
12          *   PRODUCT:   SAS
13          *   VERSION:   9.4
14          *   CREATOR:   External File Interface
15          *   DATE:      22SEP16
16          *   DESC:      Generated SAS Datastep Code
17          *   TEMPLATE SOURCE:  (None Specified.)
18          ***********************************************************************/
19             data WORK.OURDATA    ;
20             %let _EFIERR_ = 0; /* set the ERROR detection macro variable */
21             infile '.\DataFile.csv' delimiter = ',' MISSOVER DSD lrecl=32767 firstobs=2 ;
22                informat x best32. ;
23                informat y best32. ;
24                format x best12. ;
25                format y best12. ;
26             input
27                         x
2                                       The SAS System       11:04 Thursday, September 22, 2016

28                         y
29             ;
30             if _ERROR_ then call symputx('_EFIERR_',1);  /* set ERROR detection macro
30       ! variable */
31             run;

NOTE: The infile '.\DataFile.csv' is:
      Filename=E:\SAS\DataFile.csv,
      RECFM=V,LRECL=32767,File Size (bytes)=1274,
      Last Modified=28 November 2013 21:16:46,
      Create Time=22 September 2016 09:38:31

NOTE: 100 records were read from the infile '.\DataFile.csv'.
      The minimum record length was 7.
      The maximum record length was 12.
NOTE: The data set WORK.OURDATA has 100 observations and 2 variables.
NOTE: DATA statement used (Total process time):
      real time           0.00 seconds
      cpu time            0.00 seconds
      

100 rows created in WORK.OURDATA from .\DataFile.csv.
  
  
  
NOTE: WORK.OURDATA data set was successfully created.
NOTE: The data set WORK.OURDATA has 100 observations and 2 variables.
NOTE: PROCEDURE IMPORT used (Total process time):
      real time           0.05 seconds
      cpu time            0.04 seconds
      

32         
33         proc univariate data=OurData; run;

NOTE: The PROCEDURE UNIVARIATE printed pages 1-4.
NOTE: PROCEDURE UNIVARIATE used (Total process time):
      real time           0.04 seconds
      cpu time            0.03 seconds
      

34         
35         proc reg data=OurData simple
36         outest=OurModel(keep=Intercept X)
37         plots(only stats=none)=(FitPlot(nolimits));
38         model y = x;
39         run;

40         quit;

NOTE: The data set WORK.OURMODEL has 1 observations and 2 variables.
3                                       The SAS System       11:04 Thursday, September 22, 2016

NOTE: The PROCEDURE REG printed pages 5-6.
NOTE: PROCEDURE REG used (Total process time):
      real time           2.72 seconds
      cpu time            0.71 seconds
      

NOTE: SAS Institute Inc., SAS Campus Drive, Cary, NC USA 27513-2414
NOTE: The SAS System used:
      real time           3.17 seconds
      cpu time            1.01 seconds

Notes

  1. This example was based on work done with Theodor Loots (University of Pretoria) who knows SAS much better than I ever hope to achieve.
  2. I chose to present the log file instead of the output file here as it is smaller and it is where the error messages would have appeared. The Output.txt file was seven pages in length, but that’s what SAS does.
  3. In addition to the log and output files, this set of commands also generated a graph saved as OurGraph.png

SPSS, also known as PASW

I’m currently finding this is more difficult than any other software tested.

Stata

Version 14 was tested on 20 September 2016.

Command line

"C:\Program Files\Stata14\StataMP" /e do Input.do

Input file content (Input.do)

log using "Output.txt", text replace
import delimited  "DataFile.csv", delimiter(comma)
describe
summarize 
scatter y x
graph export "scatterplot.pdf", as(pdf) replace
graph export "scatterplot.eps", as(eps) replace
log close

Output file content

-------------------------------------------------------------------------------
      name:  <unnamed>
       log:  C:\...\Output.txt
  log type:  text
 opened on:  20 Sep 2016, 15:53:32

. import delimited  "DataFile.csv", delimiter(comma)
(2 vars, 100 obs)

. describe

Contains data
  obs:           100                          
 vars:             2                          
 size:           800                          
-------------------------------------------------------------------------------
              storage   display    value
variable name   type    format     label      variable label
-------------------------------------------------------------------------------
x               float   %9.0g                 
y               float   %9.0g                 
-------------------------------------------------------------------------------
Sorted by: 
     Note: Dataset has changed since last saved.

. summarize 

    Variable |        Obs        Mean    Std. Dev.       Min        Max
-------------+---------------------------------------------------------
           x |        100     51.1309    28.73384         .4      99.43
           y |        100     55.5697    27.15721       5.07     112.97

. scatter y x

. graph export "scatterplot.pdf", as(pdf) replace
(file scatterplot.pdf written in PDF format)

. graph export "scatterplot.eps", as(eps) replace
(file scatterplot.eps written in EPS format)

. log close
      name:  <unnamed>
       log:  C:\...\Output.txt
  log type:  text
 closed on:  20 Sep 2016, 15:53:32
-------------------------------------------------------------------------------

Notes

  1. The batch processing of Input.do automatically generates the corresponding Input.log, but I have also forced a specified log file within the script called Output.txt. The files are identical except for the printing of the Stata header information and a few blank lines. Use hte log file once; I’m sure you’ll prefer the output file approach instead.

  2. The use of replace in the script for commands including a file throws a warning if you do not already have these files to overwrite. I made sure these warnings do not appear here. Don’t panic if you see them when you test this workflow.

  3. I edited the path to the output file that appears in the output content given here. The full path to the actual location of this file on my hard drive is not going to help you.