Welcome to the home of TWiki.Sas. This is a web-based collaboration area for my notes about SAS, the statistical computing package from the SAS institute.

Why Use SAS?

  1. It is a long standing package and has been considerably more current than some other packages, such as SPSS.
  2. SAS has built-in some very helpful concepts that make difficult problems possible. For example, in SAS one can open several datasets at once, merge and combine them in different ways, pick and choose variables, and get a lot of stuff done that you just can't do with your garden variety statistical program, such as SPSS or STATA.
  3. SAS is the leading package in industry and if you are thinking you might go get a "real job" it is good to know SAS
  4. SAS Institute has a close relationship with KU and you can get access to SAS here more cheaply than you could in other places.
  5. Lots of other professional researchers use SAS and unless you demonstrate at least a passing proficiency with it, they will think you are not the sharpest tool in the drawer.
  6. SAS is the package that I started using in 1981 and I still think it is pretty darned good.

How do I run SAS jobs?

  1. I prefer to run SAS in BatchMode. That means I write up code, save it to a file, and run it through the SAS program.
  2. You can run SAS in GraphicalMode. If you run it on a Windows PC, you can use tools that bring in Excel Spreadsheets. That can be handy sometimes. If you run SAS in graphical mode while you are logged in on lark, you will need an X-Server in order to see the program windows.

What is the basic SAS concept?

The big big idea is that data and procedures are separated. Procedures act "on" data sets.

SAS programs have steps that define and manage data sets. These commands are usually grouped together after a statement like

Data firstProject;

This creates a dataset called firstProject and when you need to access that data at a later stage, you can use that name.

The Data step is the place where you recode and create variables.

There are two standard ways to give data to your Data step. Either you can include the numbers within the program itself, or you can save the columns of numbers in a different file and use the "infile" command. I think I've got examples of each laying around.

After creating a dataset, SAS has procedures that analyze the data. These are commonly called "PROCs".

The two stages can overlap in some instances, since it may be that a data analysis procedure writes its output back into a data set (say, to capture "predicted values" for all observations). Most of the time, we like to think of them as conceptually separate.

More About SAS Datasets

I think the best way to learn about SAS is to study example programs that work, and so go here: DataStepExamples to find more info.

With SAS, you can do MonteCarloExperiments. That means you "create" lots of datasets according to a theory and then test out an estimation tool to see how well it does across several datasets.

Don't forget Ron's SasSpecialRecipe? .

More About SAS Procedures

There are big fat manuals for SAS. The Basics manuals covers Data step stuff and some statistical Procs. Then there are addon manuals for Econometrics and Time Series, Statistics, IML (a matrix language). The expense of buying the new manuals was one of things that made me most frustrated about SAS and it still disgusts me.

I constantly look for online usage material for SAS. If you find any, let me know.

A Proc like regression is widely used, so let's consider it as an example. The whole show starts with this:

PROC REG;

If you don't tell REG what dataset you want to use, it assumes you want to use the most recently created dataset. If you need to use a different dataset, you tell it so, explicitly:

PROC REG DATA=myRealDataSet;

It may be necessary to add additional options into the PROC statement. One of the most common is that you can specify the name outputted SAS datasets. SAS can output a variety of kinds of information. One of the most important is the ability to output parameter estimates from a procedure, so they can be "grabbed" and put into another procedure. One point of concern to me is that not all SAS Procs seem to use the same precise terminology to define the output. Only a SAS manual can tell you for sure.

Supposing that in "myRealDataSet" you have a few variables, you can then run a regression model on them. Put the dependent variable on the left and the independent variables on the right:

model someVariable = someOtherVar1 someOtherVar2 someOtherVar3;

You can add options by appending a slash and adding keywords. For example, if you want the covariance matrix of the estimated b's, I believe you would write:

model someVariable = someOtherVar1 someOtherVar2 someOtherVar3/ COVB;

Another common SAS feature is the usage of the BY keyword. The By keyword can give you analysis by subsets. If you have a variable "SEX" and it has codes for men and women, then adding the command

BY SEX;

will make your proc do separate work for each value of SEX.

Go Learn More By Reading Manuals and On-Line Guides!

The SAS documents can be found on line. KU has SAS stuff up, sometimes the directory names change, but it is always someplace like this:

http://lark.cc.ukans.edu/~sas82

Click around in the sasdoc subdirectory. There are several pages they intend to welcome you, I think the most useful is:

http://lark.cc.ku.edu/~sas82/sasdoc/sashtml/main.htm

Here is the York University homepage, with tons of SAS info, including some introductory guides and nice essays intended for student usage: http://www.yorku.ca/dept/psych/lab/sas/

University of Michigan document "CSCAR Guide to Using SAS on Unix" http://www.umich.edu/~cscar/sas/sasonunix.html

They also have online SAS Language Guide: http://www.umich.edu/~cscar/sas/sasrules.html That one has a nice introduction to using math/statistical formulae to create variables in data steps Michigan State Statistical Consulting Center: http://www.fw.msu.edu/orgs/canr_big/sasmaterial.htm

Look at the SAS institute page: http://www.sas.com Follow that link to a FAQ that's detailed! http://www.sas.com/service/techsup/faq/index.html SAS has online help that is easy to browse if you have a graphical display.

Hm. http://www.psych.yorku.ca/lab/sas/

Whoa. Look at this UCLA page. http://www.ats.ucla.edu/stat/sas/library/default.htm

These ones seem especially nice:

Oliver Schabenberger's "Introduction to Manipulating Data in SAS for Windows" http://www.cas.vt.edu/schabenb/SASData.html Even though he says it is for windows, the commands are the same in Unix.

Oliver Schabenberger's "Common Tasks with the SAS System" http://www.cas.vt.edu/schabenb/SASTips.htm

USC: SAS Frequently asked questions http://www.usc.edu/isd/doc/statistics/sas/faq/

Virginia Tech "USING THE SAS SYSTEM". This is a book you can read on using SAS. Here is the URL, which does work in netscape: gopher://gopher.vt.edu:10010/02/5/126

U of Wisconsin. Tons of "Information on SAS". This site so totally kicks ass I don't believe it: http://www.stat.wisc.edu/computing/sas/

Cornell has a page with about a BILLION SAS examples and a clearly structured FAQ: http://www.ciser.cornell.edu/computing/online.html

The SAS User community page: great resources! http://faith.hypno.net/sasmass/

Frequently Asked Questions

I mean to set up an archive/FAQ database thingie here someday: SasFaq?

Maintenance of the Sas web

  •    (More options in WebSearch)
  • WebChanges: Find out recent modifications to the TWiki.Sas web.
  • WebIndex: Display all TWiki.Sas topics in alphabetical order. See also the faster WebTopicList
  • WebNotify: Subscribe to be automatically notified when something changes in the TWiki.Sas web.
  • WebStatistics: View access statistics of the TWiki.Sas web.
  • WebPreferences: Preferences of the TWiki.Sas web.

Notes:

  • You are currently in the TWiki.Sas web. The color code for this web is a (SPECIFY COLOR) background, so you know where you are.
  • If you are not familiar with the TWiki collaboration tool, please visit WelcomeGuest in the TWiki.TWiki web first.

Web TWiki Site Map Use to...
Main Home of Main web Search Main web Recent changes in the Main web Get notified of changes to the Main web Welcome to TWiki... Users, Groups ...see who is registered on this TWiki
TWiki Home of TWiki web Search TWiki web Recent changes in the TWiki web Get notified of changes to the TWiki web Welcome, Registration, and other StartingPoints; TWiki history & Wiki style; All the docs... ...discover TWiki details, and how to start your own site.
Linuxtips Home of Linuxtips web Search Linuxtips web Recent changes in the Linuxtips web Get notified of changes to the Linuxtips web ...collaborate on
R Home of R web Search R web Recent changes in the R web Get notified of changes to the R web ...collaborate on
Sas Home of Sas web Search Sas web Recent changes in the Sas web Get notified of changes to the Sas web Old notes about SAS
Swarm Home of Swarm web Search Swarm web Recent changes in the Swarm web Get notified of changes to the Swarm web Swarm Stuff
Unixtips Home of Unixtips web Search Unixtips web Recent changes in the Unixtips web Get notified of changes to the Unixtips web ...collaborate on
You can use color coding by web for identification and reference. This table is updated automatically based on WebPreferences settings of the individual webs. Contact pauljohn32@freefaculty.org if you need a separate collaboration web for your team. See also AdminToolsCategory? .
Legend of icons:   Home of web = Go to the home of the web
Search web = Search the web
  Recent changes in the web = See recent changes in the web
Get notified of changes to the web = Subscribe to get notified of changes by e-mail
(included from SiteMap; change WebHome to include from SiteMap instead of TWikiWebsTable)
 
|Powered by TWiki