Skip to Main Content

SAS

Program Conventions

A ".sas" file is where you write code to run procedures and/or commands to analyze or manipulate data.

Opening a blank .sas tab can be done on the main window of Sas. To start, open Sas on your computer and in the upper left corner of the window click on "File" --> "New Program" to begin writing code. You may also type 'control+N'.  

 

To save a .sas file, click on the floppy disk icon highlighted in the red circle.

 

undefined

We can think of a .sas file as a ‘live’ word document, where we write commands that tell Sas what to do with our data from descriptive statistics to regression models.

Sas code is written with commands which are the main function or analysis you want Sas to do in a line of code. There are two main categories for Sas commands, PROC and DATA. PROC or procedures are commands for statistical analysis of the data. DATA commands are for data manipulation and storage. 

Depending on what your kind of analysis you are doing it may require additional options to be specified. In Sas a separate line of code and a semicolon for the options is required in the code block. Options are used to indicate specific statistics or options to include in the output.

By starting a line with a “ * “, we can write notes and comments that will appear green. Sas does not recognize this as code.

 

You can also block off a section of code by starting with a " * " and ending with a " ; ".

Blocking off code

* for a block of code you want to 
  annotate start with the asterisk 
  and then end that block 
  of code with a semicolon ;

 

Sas is a statistical program you can ‘write & run’ code for analysis. To run code, that is to tell Sas what you want to do, highlight the code you want to run and click on the 'running person' button highlighted in red below. 

 

undefined