1.0 B34S Help
The B34S Data Analysis program was written by Houston H. Stokes
over the period 1972 to the present
The command B34SEXEC HELP=MANUAL NEWPAGE$ B34SEEND$
allows listing of the options and parameters of B34S commands.
If an index is desired, the keyword MAKEINDEX can be added.
If the command BOTTOMPN is added, page numbers are added. The resulting
file, using an appropriate font, can be printed with a word processor.
The B34S help facility allows the user to add help files that can easily
be accessed. Under the B34S Display Manager selective help files
can be viewed and or printed. In addition all help documents are
available under the web. Section 1.2 gives more detail on B34S HELP
commands available. The document
"B34S(r) / SAS(r) Quick Start"
Houston H. Stokes
which is available on the web, or as part of the B34S system in file
b34sqs.doc, is a Word 97 document that can be edited by the user. This
document is a quick summary of the basics need to get B34S up and
running. The B34S and SAS command structure is discussed and
illustrated.
Help for an individual command such as PROBIT can be obtained by the
command
B34SEXEC HELP=PROBIT$ B34SEEND$
The following command will list all available commands.
B34SEXEC HELP=B34S$ B34SEEND$
The General form of a B34S command is:
B34SEXEC commandname opts parms $
sentencename opts parms $
PGMCARDS$
any card image here
B34SRETURN$
B34SEEND$
All B34S commands (paragraphs) must begin with B34SEXEC. Command
input is completely free. Each paragraph consists of one or more
sentences. Each sentence must end with the delimiters ; or $. OPTS and
PARMS are separated by either a blank or a comma. PARMS can be set as
PARM1=SOMEV where SOMEV is a value or key word or as PARM1(SOMEV).
If a PARM calls for more than one value, the correct form is
PARM1=(VALUE1,VALUE2).
A B34S OPT is a key word such as NOPRINT. A PARM can optionally be
set in the form
AR(1,2,2)=.88
which is used with the B34S BTEST command. In all cases the B34S
help manual will indicate the form of what should be supplied and the
type of the arguments. The B34S language has been developed to make
running of the program easy.
Arguments are either integers (n1), real numbers (r1) which must have
decimal point or character data (key). To make input easy, values
can be passed as either KEYWORD(value), KEYWORD=value, KEYWORD=(value).
The manual lists the most logical form of input, or preferred usage,
although other forms of input are supported. The main goal of the
developer of B34S is not to hang up the user on input style. In the
B34S MATRIX command, commas have to be used in a specific and limited
number of cases such as to refer to a row
xrow2=x(2,);
or column
xcol4=x(,4);
of a matrix.
B34S paragraphs, or commands, specify a number of sentences. The B34S
paragraph must end with B34SEEND$ or B34SRUN$. Some B34S paragraphs
use the key words PGMCARDS$ and B34SRETURN$ or DATACARDS$ and
B34SRETURN$ to allow passing of card images. Card images passed with the
PGMCARDS$ sentence are listed in the B34S log while images passed with
the DATACARDS$ sentence are not listed in the B34S log. The delimiter ;
can be used in place of the delimiter $ and lower case letters can be
used for all commands, if this is desired. If B34S is called under SAS
and the ; deliminator is used, the PARMCARDS4; and ;;;; SAS statements
must be used in place of the usual PARMCARDS; and ; statements.
The B34S command structure is completely free format and is placed in
columns 1-72. Users are warned that if x is in col 72 and Y is in col 1
of the next input line, the B34S parser will see the string as XY.
Key words should not be split over lines. Comments of the form
* any comment $
can be placed inside any B34S paragraph. The B34S paragraph starts
with the B34SEXEC sentence and ends with either the B34SEEND $ sentence
or the B34SRUN$ sentence. The B34SEEND$ sentence indicates only
that the paragraph ends. While the paragraph will be parsed and
checked for errors, execution will be delayed until all paragraphs
are checked. This way syntax errors can be found without waiting for
the prior paragraphs to execute. The B34SRUN$ sentence both terminates
the paragraph and forces execution. The design objective of having the
B34SEEND$ command is to delay execution of long cpu jobs until checking
of the command stream is complete. The B34SRUN$ command will force
execution of each command (paragraph). It is dangerous to mix both
types of commands in the same job if there are multiple datasteps. The
autoexec.b34 file which customizes the b34s can contain the keyword
ALLRUN to force B34SRUN even if B34SEEND is found.
Within the B34S command, the old style generalized comment
(/$ comment) is supported but not printed if /$ is in column 1-2.
If /$$ is in col 1-3, then this comment is printed in the B34S LOG.
/; can be used in place of /$ and /;; can be used in place of /$$. As
of version 6.42g, these generalized comments can be placed
anywhere on the line. All text after /$ or /; will be removed.
Substrings /$ some text $/ can be removed IF /$ is not in col 1-2.
For example,
1
/$ This text will not be seen by the program
/$ This will come out $/ This will remain
This feature allows commenting code lines without creating sentences
model y = x z $ /$ This is best model $/
model y = x $ /$ This is second best $/
This is an alternative (slower) way to proceed
model y = x z $ * This is best model $
model y = x $ * This is second best $
Text within the command can be removed.
model y = x /$ y2 y3 $/ $
removes y2 and y3 from the command leaving the rest of the command
intact.
The generalized comment is handled differently after a B34S PGMCARDS$
or DATACARDS statement. In this situation, if the key # is added
(i. e. /$#, /$$#, /;;#, /;#) then the comment identifier is stripped
off and the rest of the line is passed to the PARMCARDS file. This
feature is useful in the FORECAST sentence or the MAKEMENU sentence
to turn off parsing of a keyword such as B34SEEND, B34SEXEC, B34SRUN
that would otherwise stop the parser. These advanced "tricks" are
mostly of interest to the B34S menu writter.
The B34S MAKEMENU command generates all B34S menus/Forms for the Display
Manager. This way the user can customize the interface. The menus
are designed to write commands. In a real sense trhe b34s menu is
just an automatic program writter. The program written can be B34S
of some other system.
In this writeup r1 is a real value, n1 is an integer and key is a
character variable.
Warning: The B34S keywords B34SEXEC, B34SEEND, B34SRUN, DATACARDS and
PGMCARDS or B34S macro commands %B34SLET, %B34SDO, %B34SENDDO,
%B34SIF, %B34SENDIF, %B34SEVAL, %B34SMACRO, %B34SMEND,
%B34SMDEBUG, %B34SMCALL, %B34SGET %B34SINC should not be
placed inside sentence comments of the form
* comments here $
If these keywords are to be commented, use the general
comment form of /$ or /$$ (/; or /;;).
It is important to note that the sentence B34SEEND$ must be used after
the last B34SEXEC paragraph if:
- The B34S SAS interface PROC CB34S is used more than one time in
a SAS job.
- PROC CB34S is used with the BY variable option.
- Any B34S old style commands are to be used.
It is recommended that the B34SEEND $ sentence be used at the end of all
paragraphs.
Since the B34S parser translates (compiles) B34S commands into lower
level code, if production jobs are run, it is possible to save compiled
code and execute B34S without parser overhead. The B34S OPTIONS command
COPYF can be used to save compiled code which can be run directly. The
casual user usually has no need for this feature and probably should
stay away from it.
INTERACTIVE OPERATION. The command B34SRUN$ can be used in place of the
B34SEEND$ command to force a B34S paragraph to execute. The B34SRUN$
command is useful if B34S is run interactively or if it is desired to
immediately execute a command in batch operation. In normal batch
operation B34S will run faster if the B34SEEND$ command is used since
the complete B34S command stream will be parsed prior to any command
being run. If B34SEEND$ is used, the only commands that execute right
away, without the B34SRUN$ command, are the HELP and OPTIONS commands.
When B34S is being run interactively with the terminal allocated to the
output and log, the user will see each command being echoed on the
terminal. Since B34S uses 132 columns, it is important to set the
printer to compressed printing. Even though only 80 columns are shown on
a PC screen, the full 132 columns will be shown on the printer. Any
commands occuring on the same line, BUT after the B34SRUN$ command
will not be parsed. In a multiple data step job, if B34SRUN$ is used
on the first data loading command, B34SRUN$ must be used prior to the
second data loading step to clean out all commands prior to loading
more data. A good rule to follow is to use B34SEEND$ everyplace.
If B34SRUN$ is used in one paragraph, it is always safe to use it
in all paragraphs. If the command ALLRUN in placed in the B34S OPTIONS
paragraph, all B34SEEND statements are automatically converted to
B34SRUN statements. On the PC, this statement canbe placed in the
AUTOEXEC.B34 file to insure that the program will process all statements
correctly. If the Display Manager is called with the statement
B34SEXEC OPTIONS DM$ B34SEEND$ inside a program, the ALLRUN option is
automatically set. If INCLUDES are used, ALLRUN will be automatically
set. For further detail, see section 1.17. Since most B34S interactive
use in under the display manager, the output and log files are managed.
This section on interactive use in only of interest to users on non
PC platforms where the display manager is not available.
Currently the Display Manager front end is available on PC, Linux,
Sun and the RS/6000 versions. Most PC users run B34S from the
Display Manager which allows users to launch jobs, look at output and
log files with user editors, make graphs and build command files, all
from within B34S.
1.1 Running B34S under Windows and UNIX
Usage and installation instructions are given below. B34S also runs on
various UNIX machines including RS/6000 and SUN workstations.
Documentation for UNIX is given at the end of section 1.4 and in
section 1.12.
For further detail on how to install PC B34S give command.
B34SEXEC HELP=INSTALL$ B34SEEND$
Running B34S.
At the command line
b34s ch2
will run the file ch2.b34 and will produce two output files:
ch2.log contains the B34S log output and should be consulted
to see if B34S has detected an error.
ch2.out contains the B34S output.
This will run with no I/O going to the screen. If the job contains
graphics and your display supports graphics, use the command
b34s2 ch2
It is recommended that you copy the files b34s.bat and b34s2.bat
to a subdirectory in the PATH so that B34S can be run from any
subdirectory.
If more space is needed, use the command form
b34s ch2 m
if you want to run the file ch2.b34 with internal work space of
M REAL*8. If M is set LE 35,000, the default space of 35,000 REAL*8
or 70,000 REAL*4 is used. The maximum size of M is limited by the size
of memory on the system.
B34S allows the user to change the workspace from inside the
Display Manager during the job. If this is done, the data will have to
be reloaded. This feature is most useful if a job is submitted from
inside the Display Manager that needs more memory than the memory that
was allocated when B34S was started. If too much memory is requested,
the user will get a message and another value can be tried. Under
Windows NT 4.00 and Windows 95, virtual memory allows more memory to be
allocated than is available in the machine. Such use, while possible, is
very slow due to operating system paging.
The command
b34s
loads the B34S and places the user in the display manager. Further
detail on the display manager is contained in section 1.20.
B34S usage notes.
- Intel 450 class machines can over run file opening statements.
B34S version 8.42d has been set with a default delay of 5
centiseconds. The command line argument ##DELAY will allow the
user to experiment with various delay times. A default time
can be set with the command ##delay_ where _ is an integer.
The default setting is ##DELAY5. DELAY can be supplied in upper
or lower case.
Since the precision on the PC is more accurate that on the
IBM 370 system, slight differences in answers across machines
will be found.
- The non IBM versions of B34S allow the user to specify a file
to be automatically executed prior to any job running. The file
must be placed in the directory containing the B34S.INI file
and must be named AUTOEXEC.B34. If the user wants the FORTMATH
option set for all jobs and any options or parameters not parsed
to be flagged, the AUTOEXEC.B34 file must contain the line.
B34SEXEC OPTIONS FORTMATH FLAG$ B34SEEND$
This feature uses unit 32 as a temporary internal unit. As
a consequence the file AUTOEXEC.B34 must not contain any
INCLUDE(32) statements or open any file to unit 32. After
the AUTOEXEC.B34 files executes, unit 32 is closed and can
be used later in the job. If the keyword EFLAG is used in place
of FLAG messages of the form ERROR: .... are produced if
parameters are specified but not parsed. This feature allows
the user to check if options have been called correctly without
stopping the program. Since the program will continue to run,
the user can turn off options with a _. For example
b34sexec rr white$ model y=x y z$ b34seend$
uses the White method to calculate the SE. The command
b34sexec rr _white$ model y=x y z$ b34seend$
turns off the White SE calculation and gives a message.
- The PC B34S produces output files that have been
optimized to be printed by the PC/DOS command PRINT. Assume
that the command
b34s ch2
had been given. The DOS command
PRINT CH2.LOG CH2.OUT
would produce nicely formatted output. You should see the
DOS manual for your computer for further detail on the PRINT
command. Some users may want to print B34S output files
from the PC on an IBM 370 mainframe. In this case traditional
FORTRAN carriage control characters are desirable. The carriage
control default can be changed by the key word ##IPCPR## being
placed anywhere on the command line. For example
RUNB34S CH2 ##IPCPR##
would produce the desired result. A alternative to the keywork
##IPCPR## is ##ipcpr##, ##OLDCC## or ##oldcc##.
-ion to turn off screen messages
-ioff to turn on screen messages
- The option ##NOMACRO## will turn off %B34SMACRO processing and
save parse space, but will allow in line code %B34SLET statements
and inline %B34SEVAL statements. This options does the same thing
as setting
B34SEXEC OPTIONS MAXMLENG(0)$ B34SEEND$
The shorter keywork ##NM## or ##nm## can be used in place of
##NOMACRO##.
These options should only be used in rare cases since the display
manager menus and graph command may not run in they contain
macros. \
- The option ##DM## or ##dm## will call the Display manager once
all executiable files have been processed. This option is the
same as coding
B34SEXEC OPTIONS DISPMON$ B34SRUN$
If the command
B34SEXEC OPTIONS DM$ B34SRUN$
is given where the prior step ended with the sentence B34SRUN$
the Display Manager is called prior to all of the command
file being run. If this command is found, after the complete job
has been run there is a final call to the display manager unless
the final command in the job stream was:
B34SEXEC OPTIONS DISPMOFF$ B34SRUN$
where the prior step ended with the sentence B34SRUN$
- The option ##DMNIF## or ##dmnif## allows calling B34S
without supplying an input file. In this mode of operation
the Display manager will come up and the user will be able to
view graphs, print graphs, edit command files and or submit
command files. If this option is coded on the command
line invoking B34S, the AUTOEXEC.B34 file must be present
in the directory C:\B34SLM\ . The RUNB34S.BAT file
automatically picks up the command file as a prefix for the
B34S output and log files. If ##DMNIF## or ##dmnif## is
supplied, there is no prefix to capture. The file
RUNB34SDM.BAT should be used to call the program in this
mode of operation is desired. The ##dmnif## switch is not needed
in the B34S win32 product.
- The option ##if## or ##IF## is used under the windows 95/98/nt
and Linux versions of B34S to call a supplied input file
and not call the Display Manager.
- The option ##allrun## or ##ALLRUN## will automatically
set all B34SEEND$ sentences to B34SRUN$ sentences. This
option is the same as placing the command
B34SEXEC OPTIONS ALLRUN$ B34SRUN$
in the command file. The ALLRUN feature can be "hard wired"
into the autoexec.b34 file if that is desired.
- The option ##NOLET## turns off both macro processing and
%B34SLET processing and will result in fast parsing. If
this option is set and %B34SLET, %B34SEVAL, %B34SMACRO &
%B34SCALL statements are found, unpredictable results will
occur. This option does the same thing as setting
B34SEXEC OPTIONS MAXMLENG(-1)$ B34SEEND$
This option is rarely used.
The shorter keyword ##NL## or ##nl## can be used in place of
##NOLET##. Use of this feature turns off all graph and menu
options under the display manager.
If the user wants to "wire" B34S to use any one of the options
##IPCRP##, ##nl##, ##nm## or ##sp##, then the RUNB34S.BAT
file should be modified to place these options on the
command line. For example:
C:\B34SLM\B34S ##sp## ##nl## %1.B34 %2 %3
will replace the current line.
Users are warned that if these options are in effect, most
menus and many test problems will not function.
The option -NODM can be used to runb b34slf95 in
silent batch mode. If this option is used the only
other options that can be used are -f -s
-d and -L in addition to the /WL options.
This mode of operation is not intended for the
average user that wants graphics etc. The only
advantage ot turning off Interacter is that no
flash is seen on the screen as the program
runs.
The command line argument
-cdir
can be used to change the directory away from the
current directory to dir. If this switch is used
the complete path must be used for the input
file.
Under windows if you are on c: and want to go to d:\junk2
use switch -cd:\junk2
Do not use spaces!!
The command line argument
-rname
can be used to reset the default names of b34s.log and b34s.out
to name.log and name.out.
Usually this task is done at the command line.
Unix type command line alternatives.
The file name and the space can be optionally set as
-ffilename
-s2000000
On Windows the drive letter can be set as
-dC
These options DO NOT require positioning and are useful in
unix. These command line switches will not work with non
interacter B34S versions at this time.
- Substantial time savings can be obtained by the use of the
PC command EMM386 and the SMARTDRV disk cache program for
the dos version.
- The Hinich Martingale test underflows and may be changed in
future releases. The same is true for the Hinich NBISP program.
These options on the BISP sentence of the BTIDEN and BTEST
commands are currently not supported.
- A new parameter SETSEED in the OPTIONS paragraph allows the
user to set the initial seed for the GGNML. If SETSEED
is set to -1.0, the SEED will be randomly taken from the time
in the machine. This will result in different answers for
bootstraps as has always been the case on MVS and CMS.
- There have been many changes to the B34S system for this port.
These changes are available on all platforms. Please report
any unexpected tracebacks to me.
B34S under UNIX
Detailed instructions for running B34S stand alone on a UNIX
platform is given in specific instructions for that version of UNIX.
The general command
b34s myjob
will run the file myjob.b34 containing B34S commands. If added space is
needed, the form
b34s myjob n
where n is space in real*4 units, should be used. Instructions for
running B34S under Speakeasy are given in section 1.12. Running B34S
under Speakeasy and stand alone are actually similar. In the first
instance, Speakeasy prepares the data loading step and passes the
commands. In the second instance, the B34S user must prepare the B34S
input files.
On Linux, RS/6000 and Sun the b34sx command will launch the
Display Manager.
B34S Versions
b34slf95.exe Runs only under Windows 95/98/NT/2000/XP and uses
Interacter Library. This version is built with
the Lahey LF95 compiler. This version is the
production version. It can be up to 4-5 times
faster than b34sw.exe.
b34sx Runs under Linux, Sun and RS/6000 and make use
of the Interacter Subroutine Library. The Linux
and Sun versions and 100% compatible with the
b34slf95 version, while the RS/6000 version lacks
IMSL support at this time.
Older B34S versions that are frozen. Do not used unless needed,
b34s.exe Runs on lower memory machines and does not
use the Interacter Library. This version is
built with the Lahey F77EM32 compiler and
uses the Spindrift and Graphoria Libraries.
This version is frozen.
b34si.exe Runs under DOS and Windows 3.1 and uses the
Interacter Library. This version is built
with the Lahey F77EM32 compiler. If you have
the memory, this is the version to use. The
Display Manager for this version is usually
run in text mode. This version is frozen.
b34sw.exe Runs only under Windows 95/98/NT except for
Matrix comman minimization which will not run
under NT. b34sw.exe is built with the Lahey LF90
compiler. The Display Manager for this version
is usually run in grahpics mode. The (esc)
key in the main Display Manager menu will
toggle between text and graphics. This
may be needed to reset the system after a
dynamic branch to an editor on some Windows
95 laptops. The b34sw version has been frozen.
All four b34s versions (Windows, Linux, Sun, RS/6000) support the same
commands. The Display Manager can be run in either text of Graphics
mode. In Text mode, no graphics are possible.
1.2 Documentation for B34S HELP Command
Options of HELP command currently supported.
HELP - Will list give a brief overview and will list currently
available commands.
DUMP - Will DUMP complete help file. This is not recommended. A
much better way is to use the form HELP=MANUAL documented
below. If HELPUNIT is used to set to another unit, the
DUMP option can be used to list a file (such as a B34S
MACRO file) in the LOG. The DUMP option will strip out
cards with --- or === in col 1-3.
NEWPAGE - If supplied starts manual listing on a new LOG page. Use
of the UIC U1 compress printing option for output allows
B34S users to obtain compact B34S manuals on-line.
BOTTOMPN - Places page number at the bottom of the page. This is
useful when making hard copy versions of the help
documents. The suggested command is:
B34SEXEC HELP=MANUAL NEWPAGE BOTTOMPN$ B34SEEND$
MAKEINDEX - Will make an index of the help manual.
HELP sentence PARAMETERS.
HELP=MANUAL - Will list currently supported B34S commands
in the log.
HELP=OLDMANUAL - Will list the old manual, if the old manual
file has been allocated to the help unit. The
old manual shows the low level B34S command
language and is only of interest to users
of B34S who want to run without the parser.
An example of such use would be a call to
a B34S procedure from a user FORTRAN
subroutine.
HELPUNIT=n1 - Changes the default help unit for this
command.
OUTUNIT=n2 - Changes output unit for help command. Usually
OUTUNIT=1.
HELPDELIM=('==') - Would change the help delimitor to the MACRO
delimitor. This would allow listing of B34S
macros in the B34S log. To use this option
the HELPUNIT option must have been specified
to point to the unit where the macros are
contained. The below listed example lists
macros TEST1 - TEST3 on unit 30. The MACRO
delimiters are removed from the listing. The
length of the string (' ') is limited to 3.
B34SEXEC HELP=(TEST1,TEST2,TEST3)
HELPUNIT=30 HELPDELIM=('==')$
B34SEEND$
HELP=(name1,name2,..) - Will list help files for command name1, name2.
Sample use of HELP command.
B34SEXEC HELP$ B34SEEND $
B34SEXEC HELP=MANUAL$ B34SEEND$
B34SEXEC HELP=(REGRESSION,QR,PROBIT)$ B34SEEND$
The B34S help file consists of a text file with === delimiters. If the
user wants to add a help file MYHELP, add the following to the help
file
===MYHELP
Any text here. As many lines as desired can be added before
the deliniter ===
===
Headings can be set with the command
---HEADINGS+++++++++++++++++
where text starts at the first +
A header can be forced with the command
---NEWHEAD
The user help file can be read with the command
B34SEXEC HELP=MYHELP$ B34SEEND$
or from the Display Manager.
Text Starting in col 20 of the ===MYHELP card is treated as a
comment.
User can optiionaly list command under ===INDEX
1.3 Documentation for SAS MACRO CB34SM
The SAS PROC CB34S currently runs with SAS version 5. It will not
run with version 6 of SAS. The SAS MACRO CB34SM is an alternative to the
PROC CB34S which can be run with all versions of SAS.
If PROC CB34S is available, it should be run instead of MACRO CB34SM
which is slower but portable. As on 2004 no SAS version 5 systems are
running B34S. Hence the CB34SM is the way to link SAS with B34S.
Example of use of CB34SM on PC using in-line datafile
* Simple job showing a branch from SAS to B34S ;
* One control file is built with data in the file;
* The job TSASB34S.SAS shows job with data in same file;
* The job TSASB342.SAS shows job with datafile & control file;
* ;
* This job is run 100% under SAS;
* ;
%include 'c:\b34slm\cb34sm.sas';
* The below listed is dfor unix ;
* %include '/usr/local/lib/b34slm/cb34sm.sas';
data junk;
input x y;
cards;
11 22
33 44
55 66
99 77
77 88
;
proc means;
* ;
* Clean files ********************************** ;
* ;
options noxwait;
run;
data _null_;
command ='erase myjob.b34';
call system(command);
command ='erase myjob.dat';
call system(command);
run;
* ;
* End of clean step **************************** ;
* ;
* Place B34S commands next after %readpgm ;
%readpgm
cards;
b34sexec list$ var x$
b34seend$
b34sexec regression$
model y = x$
b34seend$
b34sexec rr$ model y=x$ b34seend$
b34sexec describe$ b34seend$
b34sexec reg$ model y=x$ b34seend$
b34sexec options dispmoff$ b34srun$
;
run;
%cb34sm(data=junk, var=x y, u8='myjob.dat',
u3='myjob.b34',
options=nohead)
options noxwait;
run;
* ;
* This step calls b34s and copies files ;
* ;
data _null_;
command ='b34s myjob';
* use this if graphics are needed in B34S;
* command ='b34s2 myjob';
call system(command);
run;
endsas;
Sample job on PC for a job where the B34S data file is NOT in the
B34S command file. Note use of u3 and u8
* Simple job showing a branch from SAS to B34S ;
* One control file is built with data in the file;
* The job TSASB34S.SAS shows data and B34S control statements in 1
file;
* The job TSASB342.SAS shows same job with data in different file;
%include 'c:\b34slm\cb34sm.sas';
* The below listed is dfor unix ;
* %include '/usr/local/lib/b34slm/cb34sm.sas';
data junk;
input x y;
cards;
11 22
33 44
55 66
99 77
77 88
;
proc means;
* ;
* Clean files ********************************** ;
* ;
options noxwait;
run;
data _null_;
command ='erase myjob.b34';
call system(command);
command ='erase mydata';
call system(command);
* ;
* End of clean step **************************** ;
* ;
* Place B34S commands next after %readpgm ;
%readpgm
cards;
b34sexec list$ var x$
b34seend$
b34sexec regression$
model y = x$
b34seend$
b34sexec rr$ model y=x$ b34seend$
b34sexec describe$ b34seend$
b34sexec reg$ model y=x$ b34seend$
b34sexec options dispmoff$ b34srun$
;
run;
%cb34sm(data=junk, var=x y, u8='mydata',
u3='myjob.b34',
options=nohead)
options noxwait;
run;
* ;
* This step calls b34s and copies files ;
* ;
data _null_;
command ='b34s myjob';
* use this if graphics are needed in B34S;
* command ='b34s2 myjob';
call system(command);
run;
endsas;
Note: On unix the above files will work with the exception that the
include has to eb changed.
These files use the b34s.bat command. If graphics are needed in
B34S use the b34s2.bat command.
Historical notes on how this was done on IBM CMA and MVS.
For historical purposes on MVS the below listed code would use CB34SM
to run B34S under SAS
The below listed example runs SAS MACRO CB34SM on MVS.
// EXEC SASB34S
//SAS.DAT DD DSN=BEC4346.#SAS.TEST.LIB,DISP=SHR,LABEL=(,,,IN)
//SAS.SYSIN DD *
* obtain CB34SM macro ;
%INC DAT(CB34SM);
* SAS steps to load the data in DSN TEST are placed here ;
%READPGM
CARDS;
B34SEXEC REGRESSION $
MODEL Y = X Z$
B34SEEND$
;
RUN;
%CB34SM(DATA=TEST,OPTIONS=NOHEAD COR,VAR=Y X Z)
The following example runs the CB34SM MACRO on CMS. We assume the
CB34SM MACRO is in a file CB34SM SAS A1 and that the sample user
control file is in MYJOB SAS a1.
%INC CB34SM;
DATA JUNK; INPUT X Y;
CARDS;
11 22
33 44
55 66
99 77
77 88
;
* Place B34S commands next after %READPGM ;
%READPGM
CARDS;
B34SEXEC LIST$ VAR X$
B34SEEND$
B34SEXEC REGRESSION$
MODEL Y = X$
B34SEEND$
;
RUN;
%CB34SM(DATA=JUNK, VAR=X Y, OPTIONS=NOHEAD)
This file can be run using the SASB34SM EXEC which is listed next.
/* ROUTINE TO RUN SAS - B34S USING MACROS */
/* USAGE */
/* SASB34S TEST */
/* */
/* CALLS SAS TEST */
/* CALLS B34S TEST (DATA _B34SIN DATA * */
/* ADDRESS COMMAND */
'EXECIO * CP (STEM LINE. STRING QUERY V STOR'
parse var line.1 . . storage 'M'
IF STORAGE 98. Abort.';
ENDSAS;
%END;
%* changes ;
%* _NOOB=RESOLVE('&NOOB');
%* _OPT= RESOLVE('&OPTIONS');
%* PUT 'B34SEXEC DATA ' _OPT 'NOOB=' _NOOB ;
%* PUT 'B34SEXEC DATA ' &OPTIONS 'NOOB=' &NOOB ;
%*;
%IF &BY NE _$_ %THEN %DO;
%IF &IGO = 0 and &pass = 1 %THEN %DO;
PUT "b34sexec options open(&u8) unit=10 " ;
PUT " disp=old$ b34seend$ " ;
%END;
%END;
%IF &BY = _$_ %THEN %DO;
%IF &IGO = 0 %THEN %DO;
PUT "b34sexec options open(&u8) unit=10 " ;
PUT " disp=old$ b34seend$ " ;
%END;
%END;
PUT "B34SEXEC DATA " ;
PUT "NOOB = &NOOB " ;
PUT " &OPTIONS " ;
%* changes ;
%IF &WEIGHT NE _$_ %THEN %DO;
PUT "WEIGHT= &WEIGHT ";
%END;
%IF &IGO = 1 %THEN %DO;
PUT " HEADING=('&HEADING') " ;
put "filef=@@ $";
%END;
%IF &IGO = 0 %THEN %DO;
PUT "UNIT=10 HEADING=('&HEADING')" ;
put "filef=@@ $ ";
%END;
%* Passing Character data ;
%if &charvar NE _$_ %then %do;
put "CHARACTER &charvar $";
%end;
%* Character Data is passed ;
%LET BLANK = STR( );
PUT 'INPUT';
%DO I=1 %TO &NVAR;
PUT " &&V&I ";
%END;
PUT '$' ;
%* COPY DATA IF ON SAME FILE (U3=U8) ;
%IF &IGO = 1 %THEN %DO;
PUT 'DATACARDS$';
DATA _NULL_; FILE &U3 MOD linesize=72; SET &DATA; PUT &VAR;
DATA _NULL_; FILE &U3 MOD linesize=72; PUT 'B34SRETURN$'; PUT
'B34SEEND$';
%END;
%IF &IGO = 0 %THEN %DO;
DATA _NULL_; FILE &U3 MOD linesize=72; PUT 'B34SEEND$'; %END;
%* ------------------------------------------;
%* COPY B34S STATEMENTS;
%OUTPGM(UNIT=&U3)
RUN;
%* ------------------------------------------;
%MEND B34SRUN;
1.5 Sample Jobs using SAS Data Libraries
Sample Jobs for PC SAS.
Assume data on X and Y are in a file SASDATA. The below listed
job will load the DATA and make a SAS dataset jj.ssd
libname test 'c:\junk' ;
data test.jj;
infile 'c:\junk\sasdata';
input x y;
proc means;
This can be read with the SAS job
libname test 'c:\junk';
proc print data=test.jj;
These jobs can be modified to use the SAS/B34S interface MACRO CB34SM.
1.6 B34S/SAS/SCA/Speakeasy Interfaces
B34S Provides a means by which data and matrix information can be
saved in an SCA FSAVE file. Further detail on these capabilities are
contained in the SCAINPUT B34S command (see Section 31) and the
ISCAU and SCAP options in the BTIDEN and BTEST B34S commands. The
SAS interface procedures SCALINK and LINKSCA are used to provide
three way communication between SAS, B34S and SCA. The Speakeasy
LINKULES B34SIO, RUNB34S, MAKEB34S, MAKESCA and GETSCA provide
two way communication between Speakeasy and B34S, Speakeasy and
SCA, and Speakeasy and SAS, via use of the SCA FSAVE file.
- B34SIO loads B34S interface routines in Speakeasy.
- RUNB34S runs B34S under Speakeasy.
- MAKEB34S makes a B34S DATA step from inside Speakeasy.
- MAKESCA make a SCA FSAVE data file from inside Speakeasy.
- GETSCA loads data from a SCA FSAVE data file into Speakeasy.
The Speakeasy linkules B34SIO, RUNB34S, MAKEB34S, MAKESCA and GETSCA
are currently part of the Speakeasy system.
In addition B34S can call SCA, Speakeasy, RATS or SAS directly.
These options are documented in the B34S PGMCALL section.
The developer of B34S has, as a design objective, transparent use
of the four programs.
The documentation for the SAS PROCEDURES SCALINK, LINKSCA and the
Speakeasy LINKULES B34SIO, RUNB34S, MAKEB34S, MAKESCA and GETSCA are
given in section 1.11.
1.7 Documentation for SAS MACRO SCALINKM
The SAS PROC SCALINK works only on MVS for SAS 5.xx. Since SAS has
now released version 6.XX for all platforms, it is not feasable to
convert and support PROC SCALINK across these different machines. The
SAS MACRO SCALINKM was written to replace PROC SCALINK. SCALINKM runs
with minor modification on all SAS platforms and performs substantially
the same functions as SCALINK.
The below listed job, run on the PC, illustrates how SCALINKM works.
* Simple job showing a branch from SAS to SCA ;
%include 'c:\sassca\scalinkm.sas';
data junk;
input x y;
cards;
11 22
33 44
55 66
99 77
77 .
;
proc means;
* Place SCA commands next after %readpgm ;
%readpgm
cards;
print x, y.
correlate x,y.
;
run;
%scalinkm(data=junk, var=x y)
When run in SAS this file produces the following SCA procedure file.
==SASDATA
C Data loaded from SAS
input variables are @
x @
y @
. format is free.
11 22
33 44
55 66
99 77
77 88
end of data.
print x.
print y.
return.
In SCA the commands
CALL PROCEDURE is SASDATA. FILE IS 'SASSCA.MAC'
will run the job.
The SAS MACRO SCALINKM currently supports the following parameters:
DATA = sets the SAS dataset to use. Default = DSN.
VAR = sets the variables to pass to SCA. This must be
supplied.
PROCNAME = sets the SCA procedure name. Default = SASDATA.
HEADING = sets optional heading. Default = Data loaded from SAS.
BY = sets SAS variable for by variable processing.
U3 = sets the SCA command file name. Default = 'sassca.mac'
U8 = sets the SCA data file name. Default = 'sassca.mac'
The next example shows BY variable processing.
%include 'c:\SASSCA\SCALINKM.sas';
data first;
input x y;
cards;
1 7
2 5
2 4
1 6
1 3
2 6
3 6
3 7
3 4
1 8
2 4
;
proc means;
* Place SCA commands next after %readpgm ;
%readpgm
cards;
print variables are x y.
correlate variables are x y.
;
run;
%scalinkm(data=first, var=x y, BY=x)
The above job produces:
==SASDATA
C BYVALUE IS 1
input variables are @
x @
y @
. format is free.
1 7
1 6
1 3
1 8
end of data.
print variables are x y.
correlate variables are x y.
C BYVALUE IS 2
input variables are @
x @
y @
. format is free.
2 5
2 4
2 6
2 4
end of data.
print variables are x y.
correlate variables are x y.
C BYVALUE IS 3
input variables are @
x @
y @
. format is free.
3 6
3 7
3 4
end of data.
print variables are x y.
correlate variables are x y.
return.
The next sample job illustrates two calls to SCALINKM in one SAS job.
* Shows SAS calling B34S where two steps are passed;
%include 'c:\sassca\scalinkm.sas';
data first;
input x y;
cards;
11 22
33 44
55 66
99 77
77 88
;
proc means;
* Place B34S commands next after %readpgm ;
%readpgm
cards;
print x.
print y.
correlate variables are x y.
;
run;
%scalinkm(data=first, var=x y)
* ;
* pass # 2 ..... data is built;
* ;
data new; set first;
xx=x*x;
yy=y**3;
proc means;
%readpgm
cards;
print x.
print y.
correlate variables are x yy.
;
run;
%scalinkm(data=new, var=x y xx yy, procname=pass2)
Note that procname MUST be supplied in the second call.
The above code produces:
==SASDATA
C Data loaded from SAS
input variables are @
x @
y @
. format is free.
11 22
33 44
55 66
99 77
77 88
end of data.
print x.
print y.
correlate variables are x y.
return.
==pass2
C Data loaded from SAS
input variables are @
x @
y @
xx @
yy @
. format is free.
11 22 121 10648
33 44 1089 85184
55 66 3025 287496
99 77 9801 456533
77 88 5929 681472
end of data.
print x.
print y.
correlate variables are x yy.
return.
The DOS bat files SASSCA.BAT and SASSCA2.BAT illustrate how the scalinkm
procedure can be used. SASSCA.BAT
rem Call SAS and process file. SCA files are erased
erase sassca.mac
erase ft08f001
sas %1
can be used to manually call SAS. Next user gets into SCA and gives the
command
CALL PROCEDURE IS SASDATA. FILE IS 'SASSCA.MAC'.
As an alternative, the procedure SASSCA2.BAT
rem Call SAS then process SCA commands
erase sassca.dat
erase ft08f001
sas %1
sca to read only lines 1 to n
col(1,20) => get only col 1-20. Default col 1-72
******************** %B34SGET ***********************************
The %B34SGET(ARG1,ARG2,IARG3) structure allows an expert B34S
macro developer access to the internal settings of B34S. At present
the %B34SGET facility only works with %B34SLET sentences. Argument
ARG1 at present must be IB34SG, DB34SG, KB34SG of ASCII. Argument ARG2
is set to the internal B34S keyword that obtains the value. Argument
IARG3 is usually 1. At present all arguments must be explicitly set.
The command
%b34slet scolin=%b34sget(ascii,59,1);
This can be used to place a ; in places where it cannot be placed
explicitly such as
%b34slet scolin=%b34sget(ascii,59,1);
b34sexec options;
parmcards;
run%b34seval(&scolin)
b34srun;
The code
parmcards;
run;
b34sreturn;
will replace the ; by a $ if these three lines are inside a b34smacro.
When used with the key word ascii, the second arguiment mist be integer
and must be in the range 0 to 127. The Fortran char is used to move the
character. Unusual characters such as { and } can be set with 123
and 125. The character ~ is set as 126.
The below listed code shows how the GFACTOR value can be obtained.
Here all three arguments are used.
%b34slet j = %b34sget(db34sg,gfactor,1) $
b34sexec clean junk=%b34seval(&j)$ b34seend$
Providing that GFACTOR = .93, the statement
b34sexec clean junk=.93$ b34seend$
will be generated.
The %B34SGET option is intended to be used in menu writing.
******************** %B34SEVAL ***********************************
The structure %B34SEVAL( ) allows the user to write B34S code in real
time. Any analytic or character statement can be placed inside the ( ).
For example
%B34SLET I=10$
%B34SLET J=20$
B34SEXEC TEST K=%B34SEVAL(&J/&I)$ B34SEEND$
results in
B34SEXEC TEST K=2$ B34SEEND$
while
B34SLET I=10$
B34SEXEC TEST %B34SEVAL(K=&I)$B34SEEND$
results in
B34SEXEC TEST K=10$ B34SEEND
Note: The order of calculation inside the %B34SEVAL is to first
resolve all ( ). Next the calculation proceeds from left to
right using "calculator math." The expression
%B34SEVAL(40-3*4) will resolve to 37*4 and finally to 148.
The expression %B34SEVAL(40-(3*4)) resolves to 40-12 or 28.
If calculation is not possible, then nothing is done.
For further detail on how to use %B34SEVAL( ) see the rest of the
examples of the B34S Macro language.
******************** %B34SMACRO - %B34SMEND **********************
The statements
%B34SMACRO SOMENAME $
B34SEXEC LIST $ VAR %B34SEVAL(&X)$ B34SEND$
B34SEXEC REGRESSION$ MODEL %B34SEVAL(%Y) = %B34SEVAL(&X) $
B34SEEND$
%B34SMEND$
%B34SLET Y=YY$
%B34SLET X=XX$
%B34SCALL SOMENAME $
results in
B34SEXEC LIST $ VAR YY$ B34SEEND$
B34SEXEC REGRESSION$ MODEL YY = XX $
B34SEEND$
being seen by the program. An alternative to the two %B34SLET sentences
would be the structure
%B34SCALL SOMENAME(Y=YY, X=XX)$
which would result in local %B34SLETS being defined for Y and X. Note
that the %B34SMACRO is still of the form %B34SMACRO SOMENAME $
The advantage of the "local" LET design is that the same LET variable
name can differ by value. For example the code
%B34SLET II = AA$
%B34SMACRO SOMENAME $
B34SEXEC LIST $ VAR %B34SEVAL(&II)$ B34SEEND$
B34SEEND$
%B34SMEND$
%B34SCALL SOMENAME (II=BB) $
generates
B34SEXEC LIST$ VAR BB$ B34SEEND$
since the "local" II value of BB is used in place of the global
value of AA. An alternate setup would be
%B34SLET II = AA$
%B34SMACRO SOMENAME $
B34SEXEC LIST $ VAR %B34SEVAL(&II)$ B34SEEND$
B34SEEND$
%B34SMEND$
%B34SCALL SOMENAME $
which generates
B34SEXEC LIST$ VAR AA$ B34SEEND$
********************* %B34SMCALL **********************************
The structure
%B34SMCALL SOMENAME$
or
%B34SMCALL SOMENAME(LET1=ARG1 LET2=ARG2)$
are used to call a B34S macro. For an example, see the above discussion
for %B34SMACRO.
********************* %B34SIF *************************************
The structure
%B34SIF( )%THEN$
(any statements here)
%B34SENDIF$
can be used to turn off or turn on code in B34S macros or in open code.
Any analytic statement that resolves to 0 or 1 can be used inside ( ).
Note: The order of calculation inside the %B34SIF( ) is to first
resolve all ( ). Next the calculation proceeds from left to
right using "calculator math." The expression
%B34SIF((40-3*4).EQ.148) will resolve to 1 since it is true.
The expression %B34SIF(40-(3*4).EQ.28) resolves to 1 since the
calculation is first done under the ( ) and as a result it is
true.
The statements
%B34SLET I=10$
%B34SIF(&I.EQ.10)%THEN$
B34SEXEC LIST $ B34SEEND$
%B34SENDIF$
will execute since (&I.EQ.10) resolves to true (1). A simple version
would be
%B34SIF(1)%THEN$
B34SEXEC LIST $ B34SEEND$
%B34SENDIF$
while the statemment
%B34SIF(2)%THEN$
results in an error since inside ( ) is not 0 or 1.
The %B34SLET structure can be used to resolve logical character
expressions. An example is given next
/$ Tests Character with macro facility
%B34SLET i2 = test$
%B34SIF(&I2.EQ.TEST)%THEN$
B34SEXEC test$ b34seend$
%B34SENDIF$
Note that the comparison is not case sensitive. The only restriction
is that both sides of the logical statement must be valid B34S
variable names. For example TEST and TEST1 can be used but 1TEST
cannot since 1TEST is not a valid B34S name. Even though the
comparison is not case sensitive, i2 is test NOT TEST.
********************* %B34SDO **********************************
The structure
%B34SDO I=arg1,arg2,arg3 $
(any statements here)
%B34SENDDO$
results in looping for I=arg1, arg1+arg3,..., arg2. Arg3 is optional
and if not supplied, defaults to 1.
The %B34SDO structure must never be given in open code. The following
example
%B34SMACRO PRINT$
%B34SDO I=&START,&END$
B34SEXEC LIST IBEGIN=%B34SEVAL(&I) $ B34SEEND$
%B34SENDDO$
%B34SMEND$
%B34SMCALL PRINT(START=1 END=4)$
results in
B34SEXEC LIST IBEGIN=1 $ B34SEEND$
B34SEXEC LIST IBEGIN=2 $ B34SEEND$
B34SEXEC LIST IBEGIN=3 $ B34SEEND$
B34SEXEC LIST IBEGIN=4 $ B34SEEND$
as the B34S LET variable I takes the values 1, 2, 3 and 4.
********************* %B34SMDEBUG or %B34SMDBUG *********************
The structures
%B34SMDEBUG$
or
%B34SMDBUG$
produce a list of the active B34S LET variables.
*********************************************************************
A number of rules are currently in effect but may change in the future.
- Because the %B34SCALL structure, the %B34SMDBUG structure, the
%B34SLET structure and the %B34SMACRO structure are seen as
alternative paragraphs, they must not be placed inside the
usual
B34SEXEC ....... B34SEEND$
paragraph. The %B34SEVAL( ) statement can be placed inside the
usual B34S paragraph but will not be recognized unless:
- The paragraph is inside a %B34SMACRO or
there was a %B34SLET supplied outside a usual B34S
paragraph. The reason for this is that once the
parser finds a %B34SMACRO or a %B34SLET keyword,
then the MACRO processor takes over and all in place
substitutions are performed PRIOR to any more parsing
of command language.
- Nested MACRO calls up to 4 are allowed.
- Code generation macros must contain complete B34S paragraphs.
- Once a %B34SLET or %B34SMACRO is found, all macro expansion
proceeds and no code is executed until the expansion is complete.
If the program has already started running, due to a B34SRUN$
statement being found, before a B34S macro statement is found,
the user will be given a message from B34S38 that %B34SLET
storage is being initialized and that any prior macros are
lost. If this is not desired, place a dummy statement of the
form
%B34SLET DUMMY=1$
first in the job to force all macros to be resolved prior to
the job running.
- %B34SDO .. %B34SENDDO$ structures must be supplied inside
B34S MACROS.
- Unless supplied in a B34S MACRO,
%B34SIF ( )%THEN$ ... %B34SENDIF% structures must be
proceeded by a %B34SLET structure.
- The B34S Code Generation statements %B34SLET, %B34SMCALL,
%B34SIF( )%THEN$, %B34SENDIF$, %B34SDO __ = __ __$, %B34SENDDO$,
%B34SMEND, %B34SMDEBUG, %B34SMDBUG and %B34SCALL must not be on
the same line as other B34S statements. For example
%B34SLET II=AA$ %B34SLET JJ=2$
is allowed, but
%B34SLET X=100$ B34SEXEC OPTIONS LISTPARSE$ B34SEEND$
is not allowed.
- There can be one and only one %B34SCALL( ) $ per line.
- A macro variable can contain at most three & signs. I. e.
&&X&Y, &Y, &X&&Y, &X&Y are allowed but not &&X&&Y.
- Expansion of & substitutions is from left to right.
- Multiple && delays expansion. Assuming X1=VV1 and Y=1, then
&&X&Y becomes &X&Y, &X1 and finally VV1
- %B34SEVAL( ), %B34SIF( ) and the keyvalue for the %B34SLET
statement can have simple math operatios, such as +, -, *, /,
** and logical operators .EQ. .NE. .LT. .LE. .GT. .GE.
Note that .GE. is ok but . GE . will not be recognized.
For example the structure
%B34SLET I=10$
B34SEXEC LIST IBEGIN=%B34SEVAL(&I + 100)$ B34SEEND$
resolves to
B34SEXEC LIST IBEGIN=110$ B34SEEND$
The number of tokens inside the ( ) of the %B34SEVAL statement
is 40. and must be resolved to be inside 60 columns.
- The maximum number of nested %B34SIF( ) statements is 10.
The key word %THEN is optional.
- The maximum number of nested %B34SDO loops is 4.
- Nested includes each containing macro commands are not allowed.
For example assume ONE.DDD contains a list of B34S MACROS. The
command stream
B34SEXEC OPTIONS OPEN('ONE.DDD') INCLUDE(33)$ B34SRUN$
%B34SLET I=100$
%B34SCALL MACRO1$
B34SEXEC LIST IBEGIN=%B34SEVAL(&I)$ B34SEEND$
is correct. But the sequence
%B34SLET I=100$
B34SEXEC OPTIONS OPEN('ONE.DDD') INCLUDE(33)$ B34SRUN$
%B34SCALL MACRO1$
B34SEXEC LIST IBEGIN=%B34SEVAL(&I)$ B34SEEND$
will not work as expected because once %B34SLET is found
any MACROS in ONE.DDD will not be found since the B34SEXEC
OPTIONS statement will not be parsed until after macro
expansion has taken place.
- If B34SRUN$ is used in place of B34SEEND$, %B34SLET statements
must be placed prior to execution of any B34S paragraphs
except OPTIONS since MACRO storage commons may be used in the
execution of procedures. If this ordering is logically not
desired, a dummy %B34SLET of the form
%B34SLET THISIS=DUMMY$
can be used to force execution of any later macros prior to
execution of any B34S paragraphs.
The total number of B34SMACRO structures allowed is 20. The maximum
number of B34SLET variables is 100. The maximum length of all B34SMACROS
is 1500 unless increased or decreased with the OPTIONS Command MAXMLENG.
If MAXMLENG is set equal to zero in the OPTIONS sentence, no %B34SMACROS
can be supplied but $B34SLET structures are allowed in open code. If
MAXMLENG is set = -1, them %B34SLET structures and %B34SMACRO structures
are not allowed, although parsing is substantially faster. On the PC
%B34SMACRO and %B34SLET structures can be turned off with the command
line options ##nm## and ##nl## respectively. For further detail see
1.4 where specific PC options are discussed.
The below listed file shows how the Code Generation Macro facility
can be used. Since B34S will not stop for non-existant commands,
users are incouraged to experiment with Code Generation Macro
programing. Note the use of the echoed comment /$$ to annotate
the file.
/$$ define the macro TEST having a math replacement
%B34SMACRO TEST$
B34SEXEC DATA NOHEAD NOOB=%B34SEVAL(&I+&J)$ INPUT X Y$
DATACARDS$
33 44
88 99
100 200
B34SRETURN$
B34SEEND$
B34SEXEC LIST$ B34SRUN$
%B34SMEND$
/$
%B34SLET I=2$
%B34SLET J=1$
/$
%B34SMDEBUG$
/$$
/$$ shows code substitution in open code
/$$ NOOB will resolve to NOOB=2 in first DATA step and 3 in
/$$ next
/$$
B34SEXEC DATA NOHEAD NOOB=%B34SEVAL(&I)$ INPUT X Y$
DATACARDS$
33 44
88 99
B34SRETURN$
B34SEEND$
B34SEXEC LIST$ B34SRUN$
B34SEXEC DATA NOHEAD NOOB=%B34SEVAL(&I+1)$ INPUT X Y$
DATACARDS$
33 44
88 99
100 200
B34SRETURN$
B34SEEND$
B34SEXEC LIST$ B34SRUN$
/$$
/$$ Here we call the macro TEST
/$$
%B34SMCALL TEST$
/$$
/$$ Now we set a number of let variables and test Code Generation
/$$ math.
/$$
%B34SLET I = 10$
%B34SLET J = 20$
%B34SLET AI= 10.0$
%B34SLET AJ = 40.01$
%B34SLET II = 3$
%B34SLET JJ = 2$
%B34SLET AII = 3.0$
%B34SLET AJJ = 2.0$
/$$
/$$ B34SMDEBUG call lists what has been saved so far.
/$$
B34SMDEBUG$
/$$
/$$ We now test math. IS What is generated JJ = correct result
/$$
B34SEXEC JUNK0 IS=%B34SEVAL(&I + &J) JJ=30 $ B34SEEND$
B34SEXEC JUNK1 IS=%B34SEVAL(&I - &J) JJ=-10 $ B34SEEND$
B34SEXEC JUNK2 IS=%B34SEVAL(&I* &J) JJ=200 $ B34SEEND$
B34SEXEC JUNK3 IS=%B34SEVAL(&J / &I) JJ=2 $ B34SEEND$
B34SEXEC JUNK4 IS=%B34SEVAL(&II ** &JJ) JJ=9 $ B34SEEND$
B34SEXEC JUNK5 IS=%B34SEVAL(&AI + &AJ ) JJ=50.01 $ B34SEEND$
B34SEXEC JUNK6 IS=%B34SEVAL(&AI - &AJ ) JJ=-30.01 $ B34SEEND$
B34SEXEC JUNK7 IS=%B34SEVAL(&AI * &AJ) JJ=400.1 $ B34SEEND$
B34SEXEC JUNK8 IS=%B34SEVAL(&AJ / &AI) JJ=4.001 $ B34SEEND$
B34SEXEC JUNK9 IS=%B34SEVAL(&AJJ ** &AII) JJ=8.0 $ B34SEEND$
/$$
/$$ FILE TO SHOW MACRO CALLING WHERE ARGUMENTS ARE IN CALL
/$$ see also alternative way to set X=9. Note how macros
/$$ JJ, RR, ARR are set with local macro variables.
/$$
%B34SLET X(9)$
%B34SMDEBUG$
B34SEXEC JJ %B34SEVAL(&X &X &X &X &X) Y=%B34SEVAL(&X+5)$
%B34SMACRO FUNNY$
B34SEXEC JUNKPROC YY=%B34SEVAL(&I*8) YYTEST=16$
TT YY=%B34SEVAL(&X*2) G=%B34SEVAL(&ARR)
JJ=(%B34SEVAL(&JJ &RR &ARR)) $
B34SEEND$
%B34SMEND$
%B34SMCALL FUNNY(I=2 JJ=AA,RR=.9 ARR=.8) $
%B34SMDEBUG$
/$$
/$$ SHOWS ADVANCED B34S MACRO FEATURES
/$$
%B34SLET J=4$
%B34SLET JUNK="'THIS IS'"$
%B34SMDEBUG$
B34SEXEC C DATA=%B34SEVAL(&JUNK)$ B34SEEND$
B34SEXEC A DATA=%B34SEVAL("'THIS &J '")$ B34SEEND$
%B34SMDEBUG$
%B34SLET N44=&J&J$
%B34SMDEBUG$
%B34SLET N16=&J*&J$
%B34SMDEBUG$
B34SEXEC TEST44=%B34SEVAL(&N44)$
TEST16A=%B34SEVAL(&J*&J)
TEST16=%B34SEVAL(&N16)$ B34SEEND$
/$
/$ TEST %B34SIF
/$
%B34SLET I=10$
/$$
/$$ VERY SIMPLE CASE
/$$
%B34SIF(1)%THEN$
B34SEXEC SEE1 THIS SINCE SET AS 1$
B34SEEND$
%B34SENDIF$
/$$
/$$ MORE COMPLEX CASE THAT WE SEE
/$$
%B34SIF(&I.EQ.10)%THEN$
B34SEXEC SEE2 SHOULD SEE THIS SINCE I SET AS 10$
JUNK=%B34SEVAL(&I) SHOULDBE=10$
B34SEEND$
%B34SENDIF$
/$$
/$$ MORE COMPLEX CASE THAT WE DO NOT SEE
/$$
%B34SIF(&I.EQ.20)%THEN$
B34SEXEC SEE3 THIS SINCE I SET AS 10$
JUNK=%B34SEVAL(&I) SHOULDBE=WHAT I IS$
B34SEEND$
%B34SENDIF$
/$
/$$ %B34SDO LOOP EXAMPLES
/$
%B34SMACRO DO1$
%B34SDO I=1,10,2$
B34SEXEC TEST II=%B34SEVAL(&I)$ B34SEEND$
%B34SENDDO$
%B34SMEND$
/$
%B34SMCALL DO1$
/$
/$$ MORE ADVANCED EXAMPLE
/$
%B34SLET II=8$
%B34SLET JJ=10$
%B34SMACRO DO2$
%B34SDO I=&II,&JJ$
B34SEXEC TEST III=%B34SEVAL(&I)$ B34SEEND$
%B34SENDDO$
%B34SMEND$
/$
%B34SMCALL DO2$
Name Processing Example
/$ See how the name is built!!
%b34slet n=s;
%b34slet k1="'ga";
%b34slet k2=".b34'";
%b34slet name=&k1&n&k2;
b34sexec options ginclude('gas.b34'); b34srun;
b34sexec options ginclude(%b34seval(&name)); b34srun;
/$ Now test with a sample command
/$ %b34sdo must eb given in a macro, not in open code
%b34smacro bfiles;
%b34sdo i=1,10;
%b34slet start=&k1&n;
%b34slet name=&start&i&k2;
b34sexec funny file(%b34seval(&name)); b34srun;
%b34senddo;
%b34smend;
%b34smcall bfiles;
1.16 Dates in the B34S System
Background. In time series work it is important to be able to
associate a date with each observation. B34S offers a number of
facilities that can make this task easier. Assuming the SASDATEON option
is in effect (see documentation for the OPTIONS command) B34S allows the
user to save a julian date that replicates the SAS julian date sequence
that starts on 1 January 1960. If SASDATEOFF is in effect the julian
dates start in the year one (i. e. 2,436,935 days are added). The dates
can be explicitly placed in the data file and have a user selected name.
Since the date is a real*8 number, with day time marks are possible. A
date is useful for merging data or when there are missing months, or the
date can be set relative to a base date. These options are discussed
in turn:
Explicit Date Capability.
The GEN functions (see documentation for the DATA paragraph)
GEN JULDATE=JULDAYDMY(DAY,MONTH,YEAR)$
GEN JULDATE=JULDAYQY(QUARTER,YEAR)$
GEN JULDATE=JULDAYY(YEAR)$
build an explicit julian date variable in JULDATE given that the
variables DAY, MONTH, YEAR, QUARTER exist. From the julian date the
process can be reversed with:
GEN DAY=GETDAY(JULDATE)$
GEN MONTH=GETMONTH(JULDATE)$
GEN YEAR=GETYEAR(JULDATE)$
GEN QUARTER=GETQT(JULDATE)$
Fractions of a day or year are possible using the functions:
GEN XNEW=FYEAR(JULDATE)$
GEN XNEW=GETHOUR(JULDATE)$
GEN XNEW=GETSECOND(JULDATE)$
GEN XNEW=GETMINUTE(JULDATE)$
GEN XNEW=FDAYHMS(HOUR,MINUTE,SECOND)$
For further detail see DATA paragraph documentation.
Implicit Date capability.
Assuming the user has set a base date on the DATA
command or the READVBYV command using the functions
SETYEAR, SETMY, SETDMY, SETQY or SETFREQ, the commands:
GEN JULDATE=CJULDAY()$
GEN JULDATE=CDAY()$
GEN JULDATE=CMONTH()$
GEN JULDATE=CYEAR()$
GEN JULDATE=CQT()$
will get the appropriate relative julian date. If the implicit date is
set on the OPTIONS, DATA or READVBYV paragraph, it will be set at once
even if prior paragraphs have not run. This can cause problems unless
b34srun$ is used on the prior paragraph or the prior paragraphs have
already run.
Warning: It is a good idea to set the date on the DATA or READVBYV
commands. Setting the date on the OPTIONS command resets
the date for the current dataset. This allows undated
series to be loaded and the date set AFTER the data is
loaded. If after the OPTIONS SETMY( ) data is read
in without dates, then this dataset does not have a date set
with it.
The interface with RATS using the portable file allows RATS dates to be
converted to the B34S julian date automatically.
Example of date processing using DINT and DMOD functions to crack dates.
b34sexec data $
input date$
build year day month julian fyear $
gen year = dint(date/10000.)+1900. $
gen day = dint(date)-(dint(date/100.)*100.)$
gen month = dmod(dint(date/100),100) $
gen julian= juldaydmy(day,month,year) $
gen fyear = fyear(julian) $
datacards$
781229 790102 790103 790104 790404
b34sreturn$
b34seend$
b34sexec list$ b34srun$
gen statement # 1 converts 781229 to 78 then adds 1900 giving 1978.
gen statement # 2 converts 781229 to 7812 then to 781200. Finally
781229 - 781200 gives the day of 29
gen statement # 3 gives the remander of 7812/100 which will be 12
This job illustrates the power of dmod, dint and the date functions
in cracking data such as 781229.
The OPTIONS, DATA and READVBYV commands have the capability of
setting an ID variable.
IDVAR = xx Sets the character variable xx as an id variable for
the observation.
IDDATE= xx Sets the variable xx as a julian date variable to
identify each observation.
IDDATETIME=xx Sets the variable xx as a julian date variable and
indicates that time info is saved.
If the variable you want as an indicator variable is NOT character,
the GEN command REALTOCH can to used to convert the real variable
to character. If B34S detects an integer, I8 is used, If B34S detects
a floating point number, F8.1 is used. Users are cautioned that the
final number must fit in 8 characters.
1.17 B34S Display Manager System
The B34S Display Manager, available currently only on the PC versions
of B34S, allows the user to control and modify the execution of
the B34S program in real time. Version 6.xx of B34S uses the Spindrift
& Graphoria libraries for text windows and graphics respectively. B34S
versions 7.xx and beyond running on DOS, Windows 95 and Windows NT
use the Interacter library. Due to the fact that this help manual works
for all versions of B34S, there are a number of commands and options
that are available on one platform that are not available on the other
platform.
The Display manager is invoked in three ways:
- On Windows the Display Manager becomes active once the B34S icon
is left clicked or the command b34s of b34s2 is given without a
command file being supplied.
- Under DOS if the key word ##dm## or ##DM## is placed on the
b34s2 command line after the file name, then the Display
Manager will be invoked after the B34S command file has been
executed. Users wanting this mode of operation may want to
develope a special command by hard wiring the ##dm## in the
bat file script.
- If the command line
B34SEXEC OPTIONS DM$ B34SRUN$
is found in the run stream, the Display Manager will become
active once this command is executed. This will allow users to
inspect output to date and modify the execution of the B34S program.
Possible courses of actions might be:
- Terminate B34S at once if the progress to date is
not satisfactory.
- Look at B34S output to date.
- Look at high resolution graphs of the current data
series.
- Optionally edit a file to alter the progress of the
job real time.
Once the B34S DM has been called, B34S will automatically branch to the
Display Manager at the termination of the job unless the last command in
the job was:
B34SEXEXC OPTIONS DISPMOFF $ B34SRUN$
- In place of the command ##dm## on the command line, the command
B34SEXEC OPTIONS DISPMON$ B34SRUN$
can be used in the B34S job stream or placed in the automatic
file AUTOEXEC.B34 that is placed in the directory C:/B34SLM
which contains the B34S load module.
Display Manager Overview
The Display Manager allows the user to:
- Submit b34s command files and inspect the output and log files.
- View and or edit help files.
- Run and or modify example files.
- Run B34S from menus.
- Graph Series.
- Edit files with an internal editor or using an external
editor selected by the user.
- Inspect and modify the currently loaded Dataset with an
internal spread-sheet editor.
Display Manager Screen
The first Display Manager "Expert" Screen looks like this
File Edit View Tasks I/O Clean Settings Matrix Menu Help
Under "File" commands are:
1. Select file to run.
2. Enter file to run.
3. Select file to Xedit/Edit.
4. Enter file to Xedit/Edit.
5. Run member from a Macro File.
6. Print 80 col file.
7. Print 132 col file.
8. List Variables in current Dataset.
9. Exit Display Manager.
10. Quit B34S.
11. Exit Menu.
Under "Edit" commands are:
1. Edit File.
2. Edit Wide File.
3. Edit New File.
4. Edit Variable Names and Labels.
5. Edit current Dataset.
6. Create new dataset.
7. Edit B34S Log.
8. Edit B34S Output.
9. Print 80 col file
10. Print 132 col file
11. Xedit B34S log file
12. Xedit B34S out file
13. Xedit a file
14. Exit this menu.
Under "View" commands are:
1. View log
2. View output
3. View file
4. View wide file
5. View Macfile
6. View macfile List
7. Save Macfile member
8. Save log file
9. Save out file
10. Print log file
11. Print out file
12. List files in current directory
13. View Data
14. Select Basic Menu Interface
15. Toggle Expert Menu Interface
16. Exit this Menu
Under "Tasks" commands are:
1. Run Program Buffer
2. Edit Program Buffer
3. Clean Program Buffer
4. Load Shell / Example in Program Buffer
5. Load Help Buffer
6. Edit Help Buffer
7. View Help Buffer
8. Reset error condition
9. Append/Copy Program Buffer to a file
10. List Currently Active Variables
11. Run B34S from a Macro file
12. Clean a file
13. Erase a file
14. Close a file
15. List files in current directory
16. Rename a file
17. List open files
18. Copy a file
19. Exit Task Selector
Note: Choice 4 places a list of preprogram macros and
help file stubs in the program buffer. This is useful
in building a B34S program. The user can place
commmon program stubs in the shell file and access
these as needed. This feature allows the user to
customize B34S. The name of the shell file is
controlled by the SHNAME(' ') in the OPTIONS
command.
Under "I/O" commands are:
1. Browse SCA FSAVE file
2. Get SCA FSAVE file and load in B34S
3. Rewind unit and make SCA FSAVE file
4. Make SCA FSAVE file - add to files
5. Rename Files in FSAVE library
6. Run Speakeasy - No Data Passed
7. Run Matlab - No Data Passed
8. Run B34S macro file
9. Run Speakeasy - Pass Data
10. Copy Speakeasy journal files into B34S
11. Erase Speakeasy input files
12. Run Matlab - Pass Data
13. Copy Matlab Diary files into B34S
14. Erase Matlab Diary files
15. Exit to DOS
16. Exit this menu
Note: Choices 6, 9 10 and 11 require the user
license Speakeasy while choices 7, 12, 13 and 14
require a Matlab license. The Interface procedure
allows the B34S user to automaticall transfer data
to Matlab and Speakeasy and get the results of
calculations in these programs back into B34S.
Interfaces to Speakeasy and Matlab add important
important capability to the B34S system which in
this mode of operation is a data base manager.
Under "Clean" commands are:
1. Clean log file
2. Clean Output file
3. Save log file
4. Save output file
5. Reset System
6. Reset System - Clean L/O files
7. List the files in the current directory
8. Change the current directory
9. Make a directory
10. Rename a file
11. Delete a file
12. Delete a directory (must be empty)
13. Exit this Menu
These options allow the user to Rewind the log or output file.
This command is useful to save paper. In addition there are
commands edit these files and save selected output (see "edit"
menu. Under "clean" there are options to make directories,
relase files and remove directories.
Under "Settings" commands are:
1. Display Manager settings
2. Graph Setings
3. Resize B34S work space
4. Set Debug Tools
5. Setup Mouse
6. Set real*8 accuracy on/off
7. Set real*16 accuracy on/off
8. Exit this menu
Under "Matrix" commands are:
1. View / Xedit Log
2. View / Xedit Outp
3. Enter a Commjand
4. Xedit / Edit an existing Script.
5. Execute Script / Create a Script
6. Xedit a file
7. Reset System
8. Short Matrix Help
9. Full Matrix help
10. Matrix Command Help
11. Turn DScreenout on(off).
12. Load Help
13. View Help
14. Edit last command
15. Return to Run Mode
16. Clean Log file.
17. Clean Out filke.
18. Exit Matrix Command
Under "Menu" commands are:
1. Select B34S Command Input Menu/Form.
2. Select Grahp Command Input Menu/Form.
3. Select Matrix Command Input Menu/Form.
4. View Graph Menu
5. Print Graph Menu
6. Interface Menu
7. Interactive Matrix Command Menu
8. Reload the last Menu
9. Exit this menu.
This Menu loads list of menus that can be called to provide a
screen to setup a command. The menus are in the MENUNAME file.
The default name for this file is C:\B34SLM\MENU.MAC.
B34S menus are generated with the B34S procedure MAKEMENU
and as a result can be modified and or extended by users.
The menus generate B34S command language which can be
executed, saved in the program buffer and executed,
appended to the program buffer saved and executed,
saved in the program or appended to the program buffer.
These options allow the menu facility to be used to build
up a B34S command file. Information on how to develope a
B34S menu is contained in section 39.0.
Under "Help" commands are:
1. List active variables
2. Graph of a series
3. Short Help on Display Manager
4. Short Help on a Matrix Command
5. Full Help on Matrix Command
6. Load Help Buffer.
7. Edit Help Buffer.
8. View Help Buffer.
9. List files in Current Directory
10. Screen Savers.
11. About B34S.
12. Quick Start Help for New Users.
13. Load and View Help Buffer.
14. View *.pdf, *.doc & *.txt Help Files.
15. Exit this Menu
This menu allows the user to obtain help information. This
includes a listing of the currently active B34S variables and
the ability to produce view print and make file of high
resolution graphs for currently loaded series.
Note concerning use of the Display Manager with macro variables.
The currect version of the display manager does not allow the RUN
command to be used to submit sections of code that contain MACRO
variables defined in other sections of code. The reason is that once
a B34S macro variable is found, B34S will stop execution until the
complete B34S command file is generated. Next B34S will end and storage
used for MACRO variables and macros will be used by the B34S procedures.
If another file is submitted by the Display Manager RUN command that
contains %B34SEVAL( ) statements that refer to variables defined in
prior RUN statements, these will not be found. The solution is to
redefine the macros and macro variables so that as far as the B34S MACRO
variables and MACRO are concerned, what is submitted is logically
complete.
1.18 B34S Units and Files
The below list of B34S files and units is intended as a guide for the
serious B34S user. Except for unit 10 and possibly 20, units in the
range 1-20 should not be accessed by the user. Units in the range 50-90
are potential temporary scratch units. If a specific unit in this range
is desired, it should be allocated at the top of the job before it
is possibly made a scratch unit for reading macros etc.
Unit Type of File Use
1 Formatted B34S log output.
2 Formatted B34S Scratch.
3 Formatted B34S input unit.
4 Formatted PARMCARDS and DATACARDS unit.
5 Formatted B34S low level command input unit.
6 Formatted B34S output unit.
7 Formatted to dummy out I/O.
8 Unformatted Saves B34S internal data files.
9 Formatted B34S scratch unit. Used by procedures.
10 Formatted/unformatted User data unit.
11 Unformatted B34S scratch unit.
12 Unformatted B34S scratch unit.
13 Unformatted B34S scratch unit.
14 Unformatted B34S scratch unit
15 Formatted B34S help unit.
16 Formatted B34S macro unit.
17 Formatted B34S Display Manager input unit.
18 Formatted B34S Display Manager Program Buffer
19 Formatted B34S Display Manager Help Buffer
20 Formatted B34S Display Manager Shell File
32 Formatted Used by AUTOEXEC.B34 then closed.
35 Formatted Used to save Cross Products
44 Formatted SCA input file unit.
45 Formatted RATS portable file unit.
46 Formatted B34S Macro file unit.
91 Interacter Screen dump unit
92 Interacter Unit to use for replay
93 Interacter Hardcopy output unit
94 Unformatted Menu save
1.19 Missing Data in B34S
B34S supports missing values. If on the B34S DATA paragraph the
parameter FILEF=@@ (see section 13) is used then B34S will interpret na
NA, NaN and . as missing values for non-character data. The B34S missing
value code will be assigned to this series for that observation.
The MISSING=r parameter on the B34S OPTIONS paragraph (see section 2)
allows the user to select missing values. If the B34S OPTIONS option
KEEPMISS is in effect (the default) these values are left in the dataset
unless explicitly deleted using GEN statements under the DATA paragraph.
If DROPMISS is in effect, then missing data which are read or have been
built will have the observation automatically dropped. If this is not
desired, then the GEN statement
GEN X=DIFMISSING(X)$
can be used to selectively drop observations where X is missing.
An existing dataset containing missing data can be automatically
adjusted to remove observations containing missing data with the
statements:
B34SEXEC OPTIONS DROPMISS$ B34SRUN$
B34SEXEC DATA SET$ B34SRUN$
An alternative is to set DROPMISS on the DATA sentence. Either way,
DROPMISS will be in effect until explicitly changed back to the default
with the KEEPMISS command.
If missing data is left in the dataset, then the current release of
B34S allows this data to be passed to the B34S procedures. While this
may be desired with such procedures as HRGRAPHICS if it is desired to
graphically tell the location of missing data, the REGRESSION command
will give highly misleading results if missing data are passed. Users
should inspect means and maximum and minimum values of series to detect
whether missing data is in the dataset.
The FILEF=@@ option on the DATA paragraph is slower than the
FILEF=FREE option. Hence setting READMISS or using FILEF=@@ explicitly
is slower. Users should inspect their data closely to make sure that
the data that is in the sample is what was desired.
If MAXLAG is set on the DATA paragraph and in addition a GEN
statement such as
GEN D=DIFMISSING(X)$
is found, then the data file will be adjusted BEFORE any MAXLAG takes
effect. In other words, before MAXLAG advances the dataset, DIFMISSING
completely removes the observation from the dataset. MAXLAG is intended
to allow the user control over lags. DIFMISSING allows cross section
users to adjust the dataset for missing data points. Users must use the
LIST paragraph to inspect the data to make sure that file is what is
desired.
The MISSING parameter on the OPTIONS sets the default missing value.
The absolute value of any value supplied will be used. It is recommended
that the default of .1D+32 be used.
The above discussion applies only to non character data. The missing
value codes . NA and na are kept in the dataset for character data
since NA or na might be data that is valid. If the user wants to remove
these values, explicit GEN statements should be used. The below listed
sample job illustrates how this could be done.
/$ Here dropmiss will not remove 'missing' character data
b34sexec data dropmiss$ input x z$ character x z$
datacards$
11 a7
2. a8
. a9
na a0
NA a99
b34sreturn$
b34seend$
b34sexec list$ b34seend$
b34sexec data set$ build test$ character test$
gen test ='OK'$
gen if(x.eq.'.' ) test='foundit'$
gen if(x.eq.'NA')test='foundit'$
gen if(x.eq.'na')test='foundit'$
b34seend$
b34sexec list$ b34seend$
b34sexec data set$
gen if(test.eq.'foundit')test=difmissing(missing())$
b34seend$
b34sexec list$ b34seend$
Another alternative would be to directly assign the missing value code
to the character variable and use another data step to remove this
value. The disadvantage of this approach is that when listing character
data where the missing value code is explicitly entered, display
problems can occur is the LIST command is used.
If the data set read contains missing values coded with a value that is
not the B34S missing value code, then the parameter RMISSING on the DATA
paragraph can be used to automatically recode the values. It is
important that all significant digits be used. The below listed example
shows how this might be done. The coded missing value of -9999 will be
automatically replaced with the B34S missing value code.
B34SEXEC DATA RMISSING=-9999$
INPUT X Y$
DATACARDS$
11 22
33 -9999
44 55
B34SRETURN$
B34SEEND$
Problem. Assume that the user has a dataset that contains some
variables that are missing on some period and some in other periods. The
goal is to use the data that is available in a regression. The solution
is:
-1. Load the data in B34S with KEEPMISS in effect.
-2. Make a B34S DMF file.
-3. Load from the DMF just the series that are desired.
This is illustrated with the sample job shown next:
/$ Shows how to load data you want if missing values
b34sexec data keepmiss$
input x y z$
datacards$
1 2 .
11 22 .
11 22 33
. 44 55
. 55 66
b34sreturn$
b34srun$
b34sexec list$ b34srun$
b34sexec options open('test.dmf') unit=60
form=(unformatted) disp=unknown $
b34srun$
b34sexec dmf dmfmember(checkpoint) outfmt=unformatted$
create disp=rewind$
b34srun$
/$ Run b34s with part of dataset
b34sexec data filef=dmf file('test.dmf') dropmiss$
input x y$
b34srun$
b34sexec list$ b34srun$
b34sexec data filef=dmf file('test.dmf') dropmiss$
input y z$
b34srun$
b34sexec list$ b34srun$
The first DATA step loads all series keeping the missing data. This data
is saved in the file 'test.dmf' with the DMF step. The next two DATA
steps only load the data than is needed.
The B34S DMF facility allows the user to selectively load data as
needed.
The b34s DESCRIBE command can be used to determine the extent of
missing data in a file. For further information see section 47.0
The commands
b34sexec describe$ b34seend$
will list means, variances, medians, average deviation, skewness and
kurtosis for all series where there are > 2 observations without
missing data.
The command
b34sexec describe$
group(x,y,z)$
group(x,y)$
b34seend$
produces data for the observations where x, y, and z are not missing
and where x and y are not missing. The describe command will will give
the user insight into what series are missing and what overlaps there
are in the data.
Example: For version 86.7g we can drop obs # 1 and # 2 with:
b34sexec data dropmiss;
input x y;
gen if(x.eq.1.)x=missing();
datacards;
1 22
. 77
88 3
88 33
88 99
b34sreturn;
b34srun;
Problems regarding Missing Data:
In B34S the missing code is a special large number. Hence problems
can occure in the following code if statements of the form:
gen if(xx.gt.0.0)xx=0.0;
are used in place of
gen if(xx.gt.0.0.and.xx.ne.missing())xx=0.0;
The complete test file is:
b34sexec data; input x y; build xx yy;
gen xx=x;
gen yy=y;
gen if(xx.eq.-3)xx=missing();
* this will cause problems since missing is > 0 ;
* gen if(xx.gt.0.0)xx=0.0;
gen if(xx.gt.0.0.and.xx.ne.missing())xx=0.0;
datacards;
-1 1
-2 2
-3 -3
4 -4
b34sreturn;
b34srun;
b34sexec list; b34srun;
b34sexec matrix;
call loaddata;
do i=1,norows(x);
if(x(i).eq.-3.)x(i)=missing();
* this will cause problems since missing is > 0 ;
* if(x(i).gt.0.0)x(i)=0.;
if(x(i).gt.0.0.and.x(i).ne.missing())x(i)=0.;
enddo;
call print(x);
b34srun;
Note that SAS has the same problem except here missing is -0
the below listed SAS job shows the problem.
options linesize=72; run;
data test;
input x y;
cards;
1 -1
2 -2
3 -3
-999999 999999
-9 9
;
run;
data new; set test;
* illustrates bug ;
* The Y and X calculations are exact opposites ;
* Obs # 4 should be a missing. It is a 0 for x ;
* SAS sees missing as a minus!!!!!!!! ;
if x = -999999 then x = .;
if x 0 then y = 0 ;
run;
proc print; run;
Note: Even users of SAS for over 20 years can be fooled by this
example which is hard to detect!!
Missing data with a sample
If on the data step we have
b34sexec data setmy(1,1800) dropmiss;
the automatic date variable will be ruined if there is missing
data dropped. The usual message giving the range of the data will not
be correct and will be incorrectly offset by the number of dropped
datapoints since the dropmiss code does not "know" which time period
were dropped and assumes these were atgthe start of the data. If this
usual situatioon is not eh case, an error will occur.
The safe solution is to build a date variable on the fly
that is used for listings and a year variable that is used in plots.
The year variable will have fractions of the year. The variable year2
is an integer year variable.
For example
b34sexec data setmy(1,1871) iddate(date) dropmiss;
input x y;
build year date month year2 ;
gen year = fyear(cjulday());
gen date = cjulday();
gen month = cmonth();
gen year2 = cyear();
datacards;
.
.
b34sreturn;
b34srun;
1.20 Citibase Data in B34S
Estima, the developers of RATS, distribute the Citibase Macro
Datebase of over 7000 series. These series can be load in the B34S using
RATS386 version 4.20 and later of RATS32S and the B34S CITIBASE command
(see section 43). The B34S Display Manager Menu facility contains a
number of uses of this command. This is the way to proceed if the user
does not know what series to select. If the user knows what series to
select and wants to "hard wire" the data loading step, the shell program
GETCITI should be used. This program is found under the Tasks manu.
A third way to proceed is to use the utility CITIRATS and RATS386
to produce a RATS portable file which can read into B34S or directly
into RATS. As of 1996 DRI has purchased the Fame / Citibase data
library.
The steps to use the CITIBASE library are listed next:
1. Assume the CITIBASE data is saved directory C:\CITIBASE. Give the
command
SET CITIBASE=C:\CITIBASE
to set the environment.
2. Copy the file C:\CITIBASE\CITIMAXI.LST into MY.LST and edit
MY.LST to reflect only the series you are interested in.
3. Give the command
CITIRATS
to access and use {alt} F to go to the FILE menu. Use NEW to
allocate a file. A recommended name would be MY.RAT
4. Go into FILE and select "ADD FILE FROM LIST" . When asked, give
the file name MY.LST. This will produce a file MY.RAT containing
the series you have listed in MY.LST. At this point you can get
out of CITIRATS and use the MY.RAT file in RATS.
5. To get the data in B34S use RATS386 to convert the MY.RAT to a
MY.POR file which B34S can read. If the file FIX.PRG contains
dedit my.rat
open copy my.por
prtdata(unit=copy)
The command
RATS386 FIX.PRG
will produce a RATS portable file MY.POR whiuch can be read into B34S
using the SCAINPUT command. See section 31.0 below for added detail. A
small example would be the B34S job:
B34SEXEC OPTIONS OPEN('MY.POR') UNIT(45) DISP=OLD$
B34SRUN$
B34SEXEC SCAINPUT$
GETRATS $
B34SRUN$
The B34S CITIBASE command automates the rataload process. The file
c:\b34slm\ratsciti points to the exact RATS program to use. Usually
rats32s is the best choice.
Text of the file c:\b34slm\ratsciti
/$ This selects the version of rats for the citibank program
/$
/$ Inorder to use the b34s citibase procedure, the user must
/$ have a valid RATS license. For modern machines such as those
/$ running Microsoft XP, rats32s is the only program that can
/$ be used
/$
/$ b34sexec options system('rats386 _rats.in _rats.out')$
b34sexec options system('start /w rats32s _rats.in /run')$
b34srun;
1.21 Installing PC B34S
Detailed instructions for installing B34S on the PC can be obtained
by giving the command
b34sexec help=install$ b34seend$
From the Web the files ib34s.exe and ib34sw.exe install b34si.exe and
b34sw.exe respectively. B34SW.exe is designed for Windows / 95 and
Windows / NT. After down loading ib34sw.exe, the command ib34sw
will install the program. The next step is to copy the file
b34s.ini into c:\b34slm which is the recommended directory to
install the program.
To fine tune the installation, the user should set an editor
in the file autoexec.b34. If this is not desired, the internal b34s
editor can be used.
If the Windows/95 or Windows/NT B34S is installed on a disk
other than c, say in f,then the steps to get b34s operational are:
1: In the file autoexec.b34 change all c: or C: to f:
2. In the file interact.ini change all c: or C: to f:
3. In the properties for the b34sw.exe file change the
call to
f:\b34slm\b34sw.exe 100000 f
If more default memory is desired increase the
number 100000
Warning: In is highly recommended that you set the default working
directory to something other that the c:\b34slm since
it is too easy to wipe out a key file.
1.22 Advanced Graphics Options
B34S version 7.xx using Interacter Graphics contains a number of
advanced graphics options that allow control over graphics output. This
section of the manual, which has been adapted from the Interacter
Library User Guide, discusses how to use these facilities.
The file c:\b34slm\interact.ini contains a number of settings that tell
the B34S graphics what you have in your system. An example of such
a file that I use on a Gateway P5-90/150 system with an ATV video card
is given next:
rem B34S version 7.xx INTERACTER initialisation file.
rem Users must make changes as needed
rem B34S version 7.xx INTERACTER initialisation file.
rem Users must make changes as needed
charset = standard.chr
chardir = C:\b34slm\charsets\
display = 13
formdir = c:\b34slm\forms\
lfngen = 91 Screen dump unit
lfnplotin = 92 Unit to use for replay
lfnolotout = 93 Hardcopy output unit
rem PRNAME = LPT1 Where usual printer is attached
PRNAME = LPT2 Where printer is attached
rem center windows95 window
winpos= 0 0
rem ********** Uncomment your printer **************************
rem printer = 1 Generic text-only
rem printer = 2 IBM Graphics printer / 80 cols.
rem printer = 3 Panasonic KX-P1081
rem printer = 4 Amstrad DMP 3000
rem printer = 5 Epson FX type/80 columns
rem printer = 6 Epson FX type/wide carriage
rem printer = 7 Epson MX type/80 columns
rem printer = 8 Epson MX type/wide carriage
rem printer = 9 Shinwa CP80
rem printer = 10 HP LaserJet +
rem printer = 11 HP LaserJet II
rem printer = 12 IBM Graphics printer / wide carriage
rem printer = 13 HP PaintJet
rem printer = 14 HP DeskJet and DeskJet +
rem printer = 15 IBM Proprinter /80 columns
rem printer = 16 IBM Proprinter / wide carriage
rem printer = 17 Epson LQ type / 80 columns
rem printer = 18 Epson LQ type / wide 80 columns
rem printer = 19 IBM Proprinter X24/80 columns
rem printer = 20 IBM Proprinter X24/wide carriage
rem printer = 21 HP DeskJet 500C
rem printer = 22 HP DeskJet 310/32-/500/510/520
rem printer = 23 Epson JX type/80 columns
rem printer = 24 Epson JX type /wide carriage
rem printer = 25 Epson LQ color 80 columns
rem printer = 26 Epson LQ color wide carriage
rem printer = 27 DEC LN03 / LN03 + (ANSI text mode)
rem printer = 28 HP LaserJet III/4L
rem printer = 29 HP LaserJet 4/5
rem printer = 30 HP PaintJet XL 300
rem printer = 31 HP DeskJet 550C/560C
rem printer = 32 HP DeskJet 1200C
rem
rem *************************************************************
rem User next sets screen. c:\b34slm\init contains sample
rem settings for a number of screens.
rem A good first try for modern machines is VESA or display=13
rem *************************************************************
rem Tseng Labs ET4000 chipset
rem mode10 = 35 0 0 0 1 132 25 c
rem mode11 = 55 0 0 0 1 1024 768 c
rem ATI mach64
mode10 = 35 0 0 0 5 132 25 c
rem mode11 = 84 0 0 0 5 800 600
rem mode12 = 99 0 0 0 5 800 600
rem mode11 = 20226 260 0 0 18 1024 768 c
rem mode12 = 20226 259 0 0 18 800 600 c
rem **************** VESA ***********************************
rem display = 13 VESA
rem
rem *********************************************************
Unless B34S has been installed on a drive other than C, the only change
that has to be made is to uncomment your printer. The printer can
alse be reset in the program under the file menu. The printer selected
changes the type of graphics file created. By default B34S will produce
a HP-GL hardcopy file that can be reloaded with the B34S graphics viewer
under the GRAPH Display Manager command. Such files can usually be
loaded into word processing programs such as WP5.1 and MS Word. The
colors of the graph are propogated into the file. Unfortunately
WordPerfect 6.1 for DOS will not read this file. The work around is to
first fread the file into Wordperfect 5.1 or MS Word for Windows and
transfer the file to WP 6.1. The resulting document can be printed on a
color printer OR if the contrast is adjusted will print well with
black and white.
Under Windows 2K/XP the usual format is WMF.
The format of the graphics file can be changed from the FILE menu
or by using the B34S OPTIONS command GDRIVER. Usually it is a good
idea to leave the AUTOEXEC.b34 file set as
GDRIVER('C:\b34slm\HPYES.BIN')
and reset as needed inside B34S when a direct print is needed. If both
b34s.exe and b34sx.exe are on your system, it is possible to have
multiple paths in the autoexec.b34 file.
Remember to print a file to hard copy that can be loaded into the word
processor requires nothing more than a call to the GRAPH Menu and the
selection of the desired macro. To print the file directly on a printer
requires:
1. Setting the appropriate printer using either:
- A Display Manager command under FILE
- The printer = setting in interact.ini
2. Setting the form of the output file using either:
- A Display Manager command under FILE
- The B34SEXEC OPTIONS GDRIVER parameter
3. Using the DOS command PRINT name.PLT
If a printer such as a HP LaserJet 4 is selected, the print files
will be substantially bigger than those created for the plotter
or for a HP III. The sizes of the same graph in three formats is
shown next:
hp4.plt 556844 1-20-96 9:42p
hpiii.plt 144044 1-20-96 9:32p
plotter.plt 74478 1-20-96 5:03p
B34S OPTIONS HARDCOPY parameter.
The HARDCOPY parameter allows users to change internal graphics
settings. The GRAPH option of the display manager allows a user to list
the options currently in effect. These options are a function of the
1. the selected printer and 2. the hardcopy graphics format. Both the
printer and the hardcopy format can be selected under the FILE command
of the DISPLAY manager. The HARDCOPY parameter on the OPTIONS sentence
provides 26 keyword driven options. These are listed and discussed
below. If graphs are drawn from the Display Manager, in place of using
the HARDCOPY parameter is to turn on the Hardcopy menu and select the
desired options from a menu each time a print file is made.
Option # Option name Discription
1 IMAGEWIDTH Image width in points
2 IMAGEHEIGHT Image height in points
3 HORIZPOS Horizontal image adjustment in points
4 VERTICPOS Vertical image adjustment in points
5 ORIENTATION 0 = portrait, 1 = landscape
6 INVERTCOLORS 0 = no, 1 = yes, 2 = B/W only
7 USECOLOR 0 = do not use color for fills, 1= use
8 NUMCOPIES Number of Copies
9 LINEWIDTH Line thickness in tenths of a point
10 LINEJOIN Line join style. 0= mitre, 1=round,
2= bevelled
11 LINECAP Line cap 0=butt, 1=round, 2=proj square
12 FILLDENSITY Fill line density
13 PRINTDENSITY Print density (1-4) 1 highest
14 HARDWARETEXT Force hardware test 0=no, font #
15 CONTROLD Add Ctl/D to Postscript. 0=no, 1=yes
16 MAXSTROKE Max PostScript Stroke Freq (10-255)
17 CARRIAGECTRL Include carriage control 0=no, 1=yes
18 HPGLREPLAYINFO Include HP-GL Replay info. 0=no, 1=yes
19 RESETSTARTEND Reset from feed at start/end 0-3
20 TRANSPARENCY Transparency Mode. 0=no, 1=yes
21 HPGLLABELTERM HP-GL Label Terminator (ASCII code)
22 EPSFILE Generate Postscript EPS output 0=no, 1=yes
23 COLORPLANES Number of planes i raster image file 1,4,8
24 COMPRESSION 0=no data compression, 1=RLT, 2=TIFF
25 DRIVERFILL Driver Fill 0= do not use, =1 use
26 IMAGEFORMAT Raster image file Fmt. 0=PCX,
1=BMP uncompressed, 2= BMP comprtessed
27 WMFFORMAT 0= Old Windows 3.1 format
1= Aldus WMF format Default
2= Advanced WMF format
Detailed discussion of options
Assuming Drivers
1 = HP-GL Plotter
2 = HP-GL LJ ii/4
3 = Postscript
4 = Draw
5 = Raster Epson
6 = Raster HP
7 = Tek 4014
8 = Raster Image
9 = Lotus PIC
10 = AutoCAD
11 = CGM
# 1 2 3 4 5 6 7 8 9 10 11
1 * 769 756 756 576 576 737 640 - 756 -
2 * 561 540 540 432 432 552 480 - 540 -
3 28 0 0 20 - 100 0 - - - -
4 0 0 -20 - 0 70 0 - - - -
5 Land Land Land - Port Land - - - - -
6 - 2 2 2 2 2 - - - - 2
7 - - fills fills - - - - - - -
8 - 1 1 - - 1 - - - - -
9 - 5 5 5 5 5 5 5 - 5 5
10 - mit. mit. mit. - - - - - - -
11 - butt butt butt - - - - - - -
12 8 8 - - - - 7 - 15 8 -
13 - - - - 2 2 - - - - -
14 no no no no no no no no no no -
15 - - n c/d - - - - - - - -
16 - - 255 - - - - - - - -
17 no no no - - - - - - - -
18 yes yes - - - - - - - - -
19 0 - - - 3 3 - - - - -
20 - - - - - no - - - - -
21 4,5 4,5 - - - - - - - - -
22 - - no - - - - - - - -
23 - - - - - - - 1 - - -
24 - - - - - none - - - - -
25 gen dev. - - - - - - gen - -
26 - - - - - - - PCX - - -
yes = 1, no = 0
* => Default HP-GL page dimensions are plotter dependent
- => Not used for this driver / printer setup
Brief Discussion of settings
# 1 & # 2 control size of image on printed page.
# 3 & # 4 allow fine adjustment of position of image on page.
# 5 allows image to be printed in portrait or landscpace.
# 6 controls color. 0 => reproduce all colors as closely as possible.
1 => invert all graphic colors.
2 => contromise between 0 and 1
# 7 controls how colored line are to be treated when generating color
output on a monochrome device.
# 8 selects # of copies.
# 9 controls line thickness when printing at high resolution.
# 10 & # 11 control how line joins and ends are made.
# 12 controls density of hatch lines used to perform solid and
mixed-color fills using HP-GL, Tek 4014 and Lotus PIC drivers.
# 13 controls print density.
# 14 allows forcing of hardware character set regardless of on-screen
character set. This option reduces the size of the print file.
# 15 allow placing a Ctl/D terminator at end of a PostScript file. This
may be needed if the PostScript device is on a serial port.
# 16 Controls the maximum frequency of 'stroke' commands in a PostScript
file. The default of 255 might have to be reduced to stop printer
overflow messages.
# 17 Allows placement of a space carriage control character at the
beginning of HP-GL and PostScript files. This might be needed
for some Fortran oriented print spoolers.
# 18 Controls the inclusion of 'replay' information in a HP-GL file.
The default is to include such information to use the viewer.
# 19 Controls the output of reset/form feed codes on HP-GL plotters,
HP PCL printers and Epson type printers.
HP-GL 0 => don't switch plotter on/off at start/end
1-3 => switch plotter on/off at start/end
HP=PCL 0 => don't reset printer at all
1 => reset printer at end only
2 => reset printer at start only
3 => resent printer at start and end
Epson 0/2 => no form feed at end of print
1/3 => form feed at end of print
# 20 Allows 'transparency mode to me enabled when using the raster
driver to an HP PaintJet
# 21 Allows specification ASCII character to be used to mark the
end of hardware text strings generated by the Hp-GL driver (the
'label terminator'). The default is 4 (EOT).
# 22 Determines whether the PostScript driver generates files in
Encapsulated PostScript format (EPS). 0 => no, 1> yes
# 23 Sets the number of color planes in a bit image file generated
by raster image file driver. 1 => 2 colors, 4 => 16 colors,
8 => 256 colors.
# 24 Allows data compress in a HP-PCL file. 0 => no compression.
1 =>RLF compression, 2 => TIFF comptession.
# 25 Sets driver-specific fill method. 0 => uses generic method with
many adjacent horizontal lines. 1 => uses driver specific fills
when possible.
# 26 Sets raster image file format. 0 => PCX, 1 => BMP uncompressed
2 => BMP compressed.
# 27 Sets WMF format. The usual setting is 2. # 3 makes a larger file.
It is recommened that desired settings be placed in B34S macro files so
quick resets can be made.
An alternative to the HARDCOPY command is to use the PRINTERSET
feature which is activated from the Display Manager Graphics window.
This option has a printer setup menu called everytime hard copy is
requested.
The below listed job reads from testdata.wk1 produced by Excel into
b34s via rats. This job is available under SHELL from TASKS. The
user needs to:
1. Set allocate to the right number of observations
2. Be sure that the file name is testdata.wk1
3. Have the RATS386 program
/$ will read an excel generated *.wk1 file into b34s
/$ As setup assumes user *.wk1 file is testdata.wk1
/$
b34sexec options open('ratjunk') unit=60 disp=unknown$
b34seend$
b34sexec options clean(60)$ b34seend$
b34sexec options
copyf(4,60,1,999999,1,80,0,0)$
pgmcards;
* load wk1 file
allocate 20
open data testdata.wk1
data(format=wks,org=obs)
print
table
* make a portable file
open copy _rats.por
copy(format=portable)
b34sreturn;
b34seend$
b34sexec options close(60)$ b34seend$
b34sexec options system('rats386 ratjunk junkout'); b34srun;
b34sexec options system('erase junk'); b34srun;
b34sexec options open('_rats.por') disp=old unit(45)$
b34srun$
b34sexec scainput $ getrats ratsunit=45 $ b34srun$
b34sexec options close=45$ b34srun$
********************************************************
The next job reads an Excel 97 *.xls file assuming names
are in row 1 and the user has Rats versioon 5.0
********************************************************
/$ will read an excel generated *.xls file into b34s
/$ As setup assumes user *.xls file is test.xls
/$
b34sexec options open('ratjunk') unit=60 disp=unknown$
b34seend$
b34sexec options clean(60)$ b34seend$
b34sexec options
copyf(4,60,1,999999,1,80,0,0)$
pgmcards;
* load excel file
allocate 20
open data test.xls
data(format=excel,org=obs)
* open data testdata.wk1
* data(format=wks,org=obs)
print
table
* make a portable file
open copy _rats.por
copy(format=portable)
b34sreturn;
b34seend$
b34sexec options close(60)$ b34seend$
b34sexec options dodos('start /w /e rats386 ratjunk junkout');
b34srun;
b34sexec options copyfout('junkout'); b34srun;
b34sexec options dodos('erase ratjunk'); b34srun;
b34sexec options dodos('erase junkout'); b34srun;
b34sexec options open('_rats.por') disp=old unit(45)$
b34srun$
b34sexec scainput $ getrats ratsunit=45 $ b34srun$
b34sexec options close=45$ b34srun$
************************************************
Next job writes a *.csv file for up to 15 series
************************************************
/$$ This job saves the current data on unit 60 in file _EXCEL.csv in
/$$ delimit format. Excel version 5.0 can use the OPEN command
/$$ to load the data. Excel can also read a " " delimited file
/$$ like QP but the reverse appears not to be true.
/$$
/$$ Since the VAR sentence is commented out, all current B34S series
/$$ are passed
/$$
/$$ Note: If over 15 series are passed, the file will wrap.
/$$ => Pass less that 15 series
/$$
/$$ Note: CLEAN command after LIST requires LIST end with B34SRUN$
b34sexec options open('_excel.csv') unit(60) disp=unknown$ b34srun$
b34sexec options clean(60)$ b34srun$
b34sexec list output=punchexcel iunit=60$
* var $
b34srun$
b34sexec options close(60)$ b34srun$
***************************************
This job writes using RATS a *.xls file
***************************************
/$$ User must have Rats
/$$ Uses Excel 97 format
/$$ Default name junk.xls
b34sexec options open('rats.dat') unit(28) disp=unknown$ b34srun$
b34sexec options open('rats.in') unit(29) disp=unknown$ b34srun$
b34sexec options clean(28)$ b34srun$
b34sexec options clean(29)$ b34srun$
b34sexec pgmcall$
rats passasts
PCOMMENTS('* ',
'* Data passed from B34S(r) system to RATS',
'* ') $
PGMCARDS$
*
open copy $
junk.xls
copy(format=xls,org=columns)
b34sreturn$
b34srun $
b34sexec options close(28)$ b34srun$
b34sexec options close(29)$ b34srun$
b34sexec options dodos(' rats386 rats.in rats.out ')
B34SRUN$
b34sexec options npageout
WRITEOUT('Output from RATS',' ',' ')
COPYFOUT('rats.out')
dodos('ERASE rats.in','ERASE rats.out','ERASE rats.dat')
dounix('rm rats.in','rm rats.out','rm rats.dat')
$
B34SRUN$
**************************************************
Job Loads Data from a *.xls file into SAS
Job is called sasxls.sas and is found in c:\b34slm
SAS next calls B34S.
**************************************************
%include 'c:\b34slm\cb34sm.sas';
proc import out = work.test
datafile="c:\carolt\test.xls"
dbms=excel2000 replace;
getnames;
run;
proc print; run;
proc means;
* ;
* Clean files ********************************** ;
* ;
options noxwait;
run;
data _null_;
command ='erase myjob.b34';
call system(command);
* ;
* End of clean step **************************** ;
* ;
* Place B34S commands next after %readpgm ;
%readpgm
cards;
b34sexec list$ var x$
b34seend$
b34sexec regression$
model y = x$
b34seend$
b34sexec rr$ model y=x$ b34seend$
b34sexec describe$ b34seend$
b34sexec reg$ model y=x$ b34seend$
b34sexec options dispmoff$ b34srun$
;
run;
%cb34sm(data=test, var=x y,
u8='myjob.b34',
u3='myjob.b34',
options=nohead)
options noxwait;
run;
* ;
* This step calls b34s and copies files ;
* ;
data _null_;
command ='b34s myjob';
call system(command);
run;
endsas;
********************************************************
Use SAS to make an Excel file
The below listed job is SAS_EXCEL in b34sshel.mac
********************************************************
/$ Uses SAS to make an excel file
/$
/$ User must have loaded data
/$
b34sexec options open('testsas.sas') unit(29)
disp=unknown$ b34srun$
b34sexec options clean(29) $ b34seend$
b34sexec pgmcall idata=29 icntrl=29$
sas $
* sas commands next ;
pgmcards$
proc export data=b34sdata
outfile='b34sdata.xls'
dbms=excel2000 replace;
run;
b34sreturn$
b34srun $
b34sexec options close(29)$ b34srun$
/$ the next card has to be modified to point to sas location
/$ be sure and wait until sas gets done before letting b34s resume
/$ ***************************************************************
b34sexec options dodos('start /w /r sas testsas' )
dounix('sas testsas' )
$ b34srun$
b34sexec options npageout noheader
writeout(' ','output from sas',' ',' ')
writelog(' ','output from sas',' ',' ')
copyfout('testsas.lst')
copyflog('testsas.log')
dodos('erase testsas.sas','erase testsas.lst','erase testsas.log')
dounix('rm testsas.sas','rm testsas.lst','rm testsas.log')
$ b34srun$
b34sexec options header$ b34srun$
The MATRIX tabulate command provides a way to produce a comma
deliminated file
The below listed file is available under c:\b34slm\example.mac. It will
test B34S for a number of Y2K issues.
/$ Tests Y2K capability of B34S
/$
/$ day month year read in and converted to julian
/$
/$ julian = # of days since 1 Jan 1960
/$
/$ b34s data step looks at day ahead and behind
/$
/$ dates in 1400's, 1800's 1900's 2000's and 2100's tested
/$
/$ *******************************************************
/$
b34sexec options sasdateon; b34srun;
b34sexec data heading('Y2K test') idvar=cdate1;
input day month year ;
build dayinyr dbehind1 dbehind2 dahead1 cweekd iweekd
dahead2 qt cdate1 cdate2 julian julianp1 julianm1;
character cdate1 cdate2 dbehind1 dbehind2 dahead1 dahead2 cweekd;
gen julian = juldaydmy(day,month,year);
gen dayinyr = julian - juldaydmy(1,1,getyear(julian))+1.;
gen cdate1 = chardate(julian);
gen cdate2 = chardatemy(julian);
gen julianp1=julian+1.;
gen julianm1=julian-1.;
gen dbehind1= chardate(julianm1);
gen dbehind2= chardatemy(julianm1);
gen dahead1 = chardate(julianp1);
gen dahead2 = chardatemy(julianp1);
gen qt = getqt(julian);
gen iweekd = iweek(julian);
gen cweekd = cweek(julian);
datacards;
9 9 1999
31 12 1999
1 1 2000
2 1 2000
3 1 2000
28 2 2000
29 2 2000
1 3 2000
31 12 2000
1 1 1850
31 12 1899
1 1 2001
5 1 2100
1 5 1492
1 1 1999
2 1 1999
1 2 1999
1 1 1960
b34sreturn;
b34seend;
b34sexec list ; b34srun;
b34sexec list;
var julian julianp1 julianm1;
b34srun;
/$
/$ Data passed to Matrix to see it it prints OK
/$
b34sexec matrix;
call loaddata;
call names;
call tabulate(day month year julian dayinyr dbehind1
dbehind2 dahead1 dahead2 qt);
call tabulate(day month year julian julianm1 julianp1 cdate1 cdate2);
tj =chardate(julian);
tjm1 =chardate(julianm1);
tjp1 =chardate(julianp1);
iiweekd =iweek(julian);
ccweekd =cweek(julian);
julian =idint(julian);
julianm1=idint(julianm1);
julianp1=idint(julianp1);
call print('This tests calculations within MATRIX of julian data');
call tabulate(day month year julian julianm1 julianp1 tj tjm1 tjp1);
call tabulate(day,month,year,julian,iiweekd,ccweekd,iweekd,cweekd);
b34srun;
The Statistical and Engineering Division of the National Institute
of Stardards and Technology (NIST) has published a set of testing
problems that are available at
www.nist.gov/itl/div898/strd
The b34s and in many cases RATS setups for these problems are in
c:\b34slm\stattest.mac
The file c:\b34slm\stattest.b34
will run all the tests provided that the user has RATS and the
rats32s program is in the path. The "exact" answers are given
in the output so that the b34s results can be tested.
The readme file gives an overview of the nature of the tests.
The job stattest.b34 has the command
b34sexec options debugsubs(wait); b34srun;
as the first line so that the (cr) does not need to be entered
every time there is a graph.
A number of the STATTEST jobs push the B34S hard. Jobs running NLLS
in many cases will show that using the default esp2 the "exact"
answers will not be found. This is to be expected. In other jobs
such as NUMACC3 the "exact" standard deviation will not be found
for the sample unless the data is scaled. This is because the B34S
standard deviation formula in the main part of the program uses the
cross product matrix which in this case runs into accuracy problems
due to the large values of y with low variance. The final job in this
test case scales y by subtracting the integer part of the mean before
calculating the standard deviation. Here the "exact" answer is obtained.
This example shows that the older cross product approach to getting the
standard deviation and other statistics is sensitive to scaling. The
most accurate way to get OLS results is the QR approach which does
not suffer from these problems to this extent. The only thing that
can be said for the older approach is that once the cross product
matrix is calculated, regressions can easily be made without having
to reload the data. This is less and less of an advantage with
faster CPU's. In the modern period (Post 2000), the cross product
approach to regression analysis is becomming less important.
At one time the paper McCullough-Vinod (1999) JEL formula was used to
calculate the variance in the matrix command and in the describe command
as well as a number of other places including the standard deviation and
variance in the main part of B34S. However in recen years the IMSL
accuracy enhancements were found to give the same results. For further
detail see Stokes (2006) "The Sensitivity of Econometric Results to
Alternative Implementations of Least Squares" Journal of Economic and
Social Measurement.
One disadvantage of the McCullough-Vinod formula is that it requires
two passes at the data. The first pass is needed to get the mean which
is then subtracted from the data to "correct" the variance. The B34S
data step is designed to make two passes of the data.
The Box-Jenkins Section and VARMA sections of B34S use variants of
the cross product approach to obtain the standard deviation and
correlation matrix using the large sample formula. These sections of
B34S do not use the the McCullough-Vinod formula.
The McCullouch paper "Wilkinson's Tests and Econometric Software"
contains a number of interesting tests on accuracy. While the DATA
step corr option will not "pass" these tests, the CCF comamnd in the
MATRIX command will. The DATA command CORR option is intended as a quick
look at the data and not intended for high accuracy calculation of the
correlation matrix that require more than one pass at the data.
The B34S MATRIX command is intended for high accuracy calculations and
supports a number of data precisions includeing real*16 and complex*32.
The matrix command supports VPA math that allows accuracy > 1780 digits.
In addition there are imporvements to the BLAS for real*8, real*16,
complex*16 and complex*32. The command call real32on; will accumulate
and multiply using IMSL logic enhancements to real*16 and complex*32
BLAS operations. The command call real16on; uses IMSL command to imporve
accuracy while the command call real16on(:real16math); uses real*16 math
inside the blas routines for real*8. This approach is slower.