Frequently asked questions (FAQ) for SAS and R: Data Management, Statistical Analysis, and Graphics (second edition)

Ken Kleinman and Nicholas J. Horton


How can I learn more about SAS?
How can I learn more about R?
Why doesn't proc sg* work for me?
How do I tell what version of SAS or R I'm using?
How do I run the example R code from the book?
How do I have R prompt me before a plot is overwritten?
How do I have turn the name of a variable into a character vector in R?

 

Submit a question

How can I learn more about SAS?

Complete documentation is included with SAS installation by default. While there are Contents, Index, Search, and Favorites tabs in the help tool, we generally use the Contents tab as a starting point. Expanding the SAS Products folder here will open a list of SAS packages (i.e. Base SAS, SAS/STAT, etc.). Detailed documentation for the desired procedure can be found under the package which provides access to that proc or, as of SAS 9.2, in the alphabetical list of procedures found in: Contents; SAS Products; SAS Procedures. In the text, we provide occasional pointers to the on-line help, using the folder structure of the help tool to provide directions to these documents. Our pointers use the SAS 9.2 structure; earlier versions have a similar structure except that procedures must be located through their module. See Appendix A (p. 243) or the URL http://www.sas.com for more information.

How can I learn more about R?

R is a powerful and extensible free software environment for statistical computing and graphics (Ihaka and Gentleman, 1996). The book includes Appendix B (Introduction to R, p. 261), which provides a short history, installation information, a sample session, background on fundamental structures and actions, information about help and documentation, and other important topics. More information can be found at the URL http://www.r-project.org.

Why doesn't proc sg* work for me?

A new series of SAS procedures was added in version 9.2: these are not available in prior releases (see SAS 9.2: key highlights).

How do I tell what version of SAS or R I'm using?

The version number of SAS is included at the top of the log file (see Appendix A, p. 244). The version number of R is displayed when the program is started. In addition, the R.Version() command can be used to capture this information.

How do I run the example R code from the book?

There are two options:
  1. open the appropriate file on the examples web page, then cut and paste into R
  2. run the command:

    source("http://www.math.smith.edu/sasr/examples/chapterX.R", echo=TRUE, max.deparse.length=4096)
    replacing "X" with the appropriate chapter number.

How do I have R prompt me before a plot is overwritten?

There are two options:
  1. run the command: devAskNewPage(ask=TRUE) prior to running your commands
  2. run the command: par(ask=TRUE) prior to running your commands (note, this usage is deprecated)

How do I have turn the name of a variable into a character vector in R?

This can be done using a nesting of the deparse() function (which turns an unevaluated expression into a string) and substitute(), which is often used to create informative labels (thanks to Gérald Jean). As an example, consider:
varstring <- deparse(substitute(varname))

See also help(quote).

 

Submit a question