Notes on Using SAS Code at this Site
The SAS code at this site is being made available to anyone who can
figure out how it works and what it is good for. Neither the author
(usually, but not always, John Blodgett), OSEDA
or the Missouri Census Data Center
take any responsibility regarding the suitability or reliability of the
software. Use at your own risk! We do encourage feedback from
users who have detected problems with the software and we will make attempts
to correct any known errors.
Redistribution of the code or inclusion in other software products is
permitted provided that adequate attribution of the original authors is
maintained within the source code.
This code is developed within a coding environment that assumes the
presence of certain tools and libraries. The code will not worked
when moved to a different environment unless these environment modules
are replicated in the new environment. There are 3 major categories
of such modules:
SAS macro references. You may encounter code within a module
such as %cnvtdlm(setin=<someset>,labels=1)
that will be flagged as an apparent unresolved macro reference. We
use SAS system options mautosource and sysautos so that SAS will always
search for such unresolved macro references in our local macro library
(and then in the standard macro libraries provided by SAS Institute).
In order to make this problem go away when transporting the code to your
site, you need to transfer the corresponding SAS macro source code to your
site and then make it available to your environment. You can access
the OSEDA/MCDC SAS macro library at http://mcdc.missouri.edu/sasmacro
This page will present you with an alphabetical index listing of all
the modules in the library (directory). To find the module for the unresolved
macro just look for a file with the same name as the macro and an extension
of ".sas". So, for example, to get the source code for the %cnvtdlm macro
you would look for a file named cnvtdlm.sas . You need to transfer this
file to your local system. If you have your own local autocall macro library
you can store the code in a module with the same name (i.e., cnvtdlm.sas)
and it should then be available at your site. Or, you can save the
file to any file on your system and add a line of code to your SAS program
to include the file prior to invoking it. This might look something
like: %include "c:\mymacs\cnvtdlm.sas". A third alternative
would be to actually include the macro code directly in your program prior
to invoking the macro. This may well be the best option for short
macros. You can typically do this with copy and paste without need
to do a file transfer.
%include sascode(<module>) references. In addition
to the macro library, we maintain a separate library of non macro SAS formats.
This are typically small modules and are often templates that are used
to create customized code. But occasionally, we will directly access
one of these modules in another SAS program. The strategy
for getting this code over to your local environment is similar to what
you have to do with macro code. Here the library is sascode instead
of sasmacro so the URL to access the directory is http://mcdc.missouri.edu/sascode
As with the macro library directory, you need to look for the
file with the name of the module being referenced and with a ".sas" extension.
For example, if the program you are trying to run contained the statement
then you would look for a file named doitloop.sas. As
with the macro library module, you could either transfer this file to your
system and change the %include statement to reference your local copy,
or you could do a simple copy-paste to insert the code directly into your
Important note for users having trouble browsing .sas
files: You may have trouble trying to simply use your browser
to view these .sas files, because your browser (probably MS Internet Explorer)
wants to start up a local SAS session to process the file, rather than
letting you view/download the file. An alternate way to access
these files that should avoid this problem is to use our uexplore
software to traverse these directories. Using this tool is primarily
intended to provide you with access to our SAS data holding, but it will
also permit access to many "plain text" files using a simple interface
program that will hide the file extension from your browser.
To access the sascode directory via uexplore the URL would be
. Change "sascode" to "sasmacro" here and you will be viewing
the SAS macro library. The directory will look different -- there
may even be some descriptive text associated with some of the modules to
help those who are "shopping" for modules.
Note that we are providing you with all references to the
web site mcdc.missouri.edu and to directories in the /pub area.
If you have used our site over recent years, you were accessing these modules
using URLs such as http://www.oseda.missouri.edu/cgi-bin/uexplore?/mscdc/sascode@secure
. This URL will still works, but it points to a server where we have
copies of our software, but where we may not be maintaining it. So
you are strongly advised to always look for the copies on the mcdc server.
As an aside for those interested in how we automate some of our local
SAS environment you might want to look at the module autoexec8.sas
in the sascode directory. This is the module that we automatically
execute at the start of each SAS job, which handles things such as the
automatic access to our macro and SAS formats libraries.
SAS format codes. This may be the most common problem
you'll incur when using our software. We really like to use permanent
SAS format codes, for all sort of things beyond just providing simple value
labels for PROC FREQ, etc. We use them a lot as a tool for doing
table lookup, in conjunction with the put function. Typically,
you will encounter a line of code such as
and you will get an error message saying that SAS was unable to find
the format module $county. In our environment we have compiled a
great many such format modules and stored them in a SAS formats catalog
and have used the system option fmatsearch to make those formats accessible
to our programs. Specifically, in our autoexec8.sas module (mentioned
above) we have the lines:
libname sasctlgs '/pub/sas/catalogs'
options fmtsearch=(work sasctlgs sasuser);
which tells SAS to look for unresolved format references first in work.formats
(this is where formats that have been created in the current program get
stored by default) and then in sasctlgs.formats -- which is where we have
stored all our compiled formats. You should not attempt to
access our formats catalog, but what you can do is reference the
SAS source modules corresponding to each of our formats. You
can then use these source modules in order to create the format codes (possibly
with editing to suit your needs) at your site. So, for example,
to use our $county format code (which takes 5-character FIPS county codes
as arguments and returns the name of the county corresponding to that code
as the label) you would access the source code by going to http://mcdc.missouri.edu/sas/formats/
and then selecting the file Scounty.sas from the directory listing.
(You can also add "Scounty.sas" to the URL shown to go directly to
the source code for $county. Note the uppercase "S" in the filename.
This is the UNIX substitute for the "$" symbol that indicate a character
type format (i.e. a format that works on character type arguments.)
This naming convention has its origins in the MVS environment where we
first created many of these format modules. On MVS they were all
stored in a format library PDS and the member names actually began with
$ characters (somewhere in the world there may still exist something called
To use this format code on your system download
the source file to your system and then use it as input to the SAS format
procedure. All these format modules consist of extensive comments
to document the codes and then a single proc format VALUE statement.
To use $county in a program at your site, you should add the
following code to your program (prior to the first step in your job that
references the format code):
%include 'c:\myformats\Scounty.sas' ;
This assumes that you transferred the source code to the file as shown
on your Windows system. You can stored the code anywhere you want
to, of course. You can also bypass the file transfer option
and just browse the format source module and use copy-paste to insert the
format value statement directly into your program (in place of the %include
statement as shown in the above sample). Of course, if you
think you would like to use the format in many or any programs at your
site, you should consider not only copying the source module, but actually
saving the compiled version in a permanent formats catalog and setting
options (read about the fmtsearch SAS system option if you are not familiar
The purpose of this document is to provide answers to the frequently
asked questions regarding the SAS code that people obtain from our site.
In doing so, we have pointed you to several critical shared resource libraries
that are referenced by many of our other various application modules.
The latter SAS programs are distributed about the data archive, which is
organized primarily based on entities we call filetypes.
A filetype is just a broad category of data, such as 1990 Summary Tape
File 3, or 2000 Public Law 94. Most of the SAS programs available
on our site are stored in subdirectories named Tools within filetype subdirectories.
So, if you are looking for code related to the 2000 Public Law 94-171 data
files, you would want to look at either http://mcdc.missouri.edu/data/pl942000/Tools/
or (using our uexplore application, which can sometimes provide useful
guidance in the form of short file descriptions) http://mcdc.missouri.edu/cgi-bin/uexplore?/data//pl942000@secure
. Of course, how would you even know there was such a filetype
directory as pl942000 (maybe it was called just pl94 or pl94-171)?
To see the list of current filetypes you should point uexplore one directory
level higher using the URL http://mcdc.missouri.edu/cgi-bin/uexplore?/data/@secure
. Finally, to confuse matters just a little bit more, you should
be aware that we are currently (June, 2001) running two versions
of the uexplore software, on two different servers - the old one and the
new one. Our goal is to convert all or most of our data holdings
over to the new server by the end of this summer. But for now, we
still have good data on the old server that is not yet available on the
newer, faster one (mcdc). To access the data on the old server use
the URL http://www.oseda.missouri.edu/cgi-bin/uexplore?/mscdc/data@secure
or go to the author's home page (http://oseda.missouri.edu/jgb)
look at the links in the second row.
Question or comments can be address to the author at Glenn Rice.