University Statistics
Internal
Contacts
|
SAS Formats
Formats. What are they good for?
Although working with codes all day is fun, sometimes formats are needed to make our cryptic data intelligible to humans. The two purposes of our formats are:
1. Applying a label or name to a code (eg. to display the course name associated with a course code)
2. Mapping from one variable to another (eg. to determine which faculty a school belongs to)
It makes sense that we use a common set of formats, and on this page, these shared formats are documented. To use them yourself, make sure your "autoexec.sas" file (which is run whenever SAS starts up) contains the following line -
libname library
'p:\stats\sasprod\formats';
To apply a format within a data step, write a put statement like this -
course_name = put(course, $ps_course.);
Naming Convention
Formats should be given names that explain exactly what they do. These shared formats are named using the following principles -
-
They are all prefixed by a "ps_" indicating Planning Services. This is an interim measure, and when the transition to new formats finishes, this can be removed.
-
If the format maps from one variable to another, then separate the two variables by a "2" eg. - ps_school2faculty
-
If the format applies a label or name to a code, then merely call it by the name of the variable, eg ps_school
-
Abbreviations are not used, so for example faculty is used rather than fac.
-
An underscore is used to separate words in a format name, eg. ps_entrance_category
-
The format name is the same as the SAS program used to generate it. It makes it simple to find.
-
Mapping to a code, the format is just the name of the variable eg. school2faculty_code.sas
maps from school to faculty code whereas school2faculty.sas maps to the faculty name.
- Maximum format name length is 31 for character formats and 32 for numeric.
|
Description of Formats
Hover over name for further description, click name to see content of format
(Revised 30 Oct 2009
)
|
|
Creating New Formats
If you need a format that isn't listed here, then use the SAS code in
p:\stats\sasprod\formats\revolution\ as a template for
creating the new format. Your header must be contain the following elements:
/* *************************************************************************
* FILE: ps_broad_field_of_education.sas
* INFO: Broad fields of education - DEEWR codes<br />e.g. '02' -> 'Information Technology'
* UPDATER: Bart Simpson
* WHEN: 16-Jul-2009
* SOURCE: Callista (direct)
* ************************************************************************* */
The INFO: line is used as the content for the tooltip describing the format. Use the
<br /> tag as a tooltip linebreak, and include an example of the format, if possible.
When you have created your format follow the procedure below to document it and make it
available to everyone.
- Run it in SAS to add it to the shared library (named 'library')
- Run \revolution\code\ExportFormats.sas to create a listing of
relevant formats in \revolution\code\SAS_output.html.
- Run (or get another programmer to run) the Perl script
\revolution\code\ParseFormats.pl. This creates the HTML
describing the formats, and saves it in w:/internal/sas_formats/.
- Copy the contents of \revolution\code\formatSummary.html
between the lines indicated by
<!-- Copy from following line into MySource -->
.
.
.
<!-- Copy to previous line into MySource -->
into www.stats.uwa.edu.au/Internal/sas_formats/formatsummary.
Note that strawberry perl can be installed easily - download and unzip the package then type "cpan"
and then type "install". |
|