SAS Syntax Basics Screenshots Tutorial
SAS Syntax Basics
- Statements in SAS are like sentences. The punctuation though is a semicolon (;) rather than a period (.)
- Most statements (but not all) start with an identifying key word (e.g. proc, data, label, options, format...)
- Statements are strung together into sections similar to paragraphs. These paragraphs in a Windows OS are ended with the word "run" and a semicolon.
SAS Syntax Rules
- SAS statements are format free.
- One or more blanks or special characters are used to separate words.
- They can begin and end in any column.
- A single statement can span multiple lines.
- Several statements can be on the same line.
SAS Free Format
Using the free-format Syntax
rules of SAS though can make it difficult for others (or you) to read your
program. This is akin to
writing a page of text with little attention to line and paragraph breaks. You may still have
Capital letters and periods, but where a sentence begins and ends may be a bit confusing.
Using the free-format Syntax rules of SAS though can make it difficult for others (or you) to read your program. This is akin to writing a page of text with little attention to line breaks. you may still have capital letters and periods, but where a sentence begins and ends may be a bit confusing. Isn't this paragraph and this example of a sas program easier to read?
SAS Comments can be used to provide additional information, reminders, or to keep a part of the program from running without deleting it. Note that above example has a comment in green about the labels. Another comment (in green) keeps the options statement from running with the rest of the program.
- Type /* to begin a comment
- Type your comment text
- Type */ to end the comment
- Or type an * at the beginning of a line. Everything between the * and the ; will be commented.
- Alternatively, highlighting the text that you would like to comment and use the keys Ctrl / to comment the line. To uncomment a line, highlight and use the Ctrl Shift / keys.
For additional questions or assistance, contact Tina Ughrin.