Docsity

SAS Programming: Rules, Data Sets, and Input Statements - Prof. James Davenport, Study notes of Statistics

Toggle sidebar
bg1
ORules for SAS Statements -- See Online Help & Textbook
1. Every SAS statement must end in a semicolon.
2. SAS statements can be in upper- or lower-case
3. Statements can continue on the next line (as long as you
don’t split words in two).
4. Statements can be on the same line as other statements.
5. Statements can start in any column.
O Comment statements
/* Everything between is a comment */
* This is a one line comment statement. ;
ORules for SAS names -- See Online Help & Textbook
1. Names must be 32 characters or fewer in length, but there
are exceptions (Librefs, filerefs, etc. must be 8 characters
in length; informats must be 31 characters or fewer, and
format names may be up to 32 characters.
2. Names must start with a letter or an underscore ( _ )
3. Names can contain only letters, numerals, or underscores.
4. Names can contain upper- and lowercase letters.
1
pf3
pf4
pf5

Partial preview of the text

Download SAS Programming: Rules, Data Sets, and Input Statements - Prof. James Davenport and more Study notes Statistics in PDF only on Docsity!

O Rules for SAS Statements -- See Online Help & Textbook

  1. Every SAS statement must end in a semicolon.
  2. SAS statements can be in upper- or lower-case
  3. Statements can continue on the next line (as long as you don’t split words in two).
  4. Statements can be on the same line as other statements.
  5. Statements can start in any column. O Comment statements /* Everything between is a comment */
  • This is a one line comment statement. ; O Rules for SAS names -- See Online Help & Textbook
  1. Names must be 32 characters or fewer in length, but there are exceptions (Librefs, filerefs, etc. must be 8 characters in length; informats must be 31 characters or fewer, and format names may be up to 32 characters.
  2. Names must start with a letter or an underscore ( _ )
  3. Names can contain only letters, numerals, or underscores.
  4. Names can contain upper- and lowercase letters.

O SAS Data Set (32,767 variables and ??? rows) (# rows is only limited by the resources on your computer)

  1. What is it? What creates it?
  2. How does the Data Step Work?
  3. What you supply to SAS so it can construct a SAS Data Set? O Consider Figures 2.1, 2.2, 2.3 & 2. Raw data outside computer
  4. any word processor
  5. Microsoft’s Access
  6. Epiinfo – “Make View” and “Enter Data”
  7. dBase ZZZ
  8. SAS fsp
  9. Spreadsheets (Lotus, Quatropro, NCSS, etc.) (either as ASCII files or directly to SAS Data Sets) O SAS Data Structure  rectangular array (casewise data entry)  --- each row, record, etc.  --- observation(s) on a single experimental unit, case, subject, item, individual, etc.  --- each column, field, etc.  --- a different variable  missing data? In SAS every variable EXISTS for every observation. Thus missing values must be assigned some sort of character. missing value ----- ". " i.e. a period !!!!  SAS Data Set descriptor portion

--syntax is checked --statement is compiled (if correct) --input buffer is set-up (records, cards, data lines, etc.) --program data vector is set-up and all variables are set to missing values --descriptor portion is initialized -- among other things, the six characteristics of each variable are initialized  Name  Type  Length  Informat  Format  Label During Execution Phase: --each record is read processed and written to the program data vector --When the ending of a Data Step is encountered ...

  1. current observation is written to the data set
  2. program loops to the top of the Data Step
  3. variables in the data vector are set to missing values (a period for numerical data and a blank for character variables) The Data Step continues & iterates as many times as there are

records to read. Then the Data Step is closed & SAS goes on to the next Data Step or Proc Step. Info that you supply to create a SAS Data Set --input statements to tell SAS how to read the records --definitions of variables & indicators of whether they are numeric or character --specific location of raw data (cards, file, tape, cassett, etc.) TELLING SAS HOW TO READ THE DATA : Styles of Input There are three basic input styles as well as various format modifiers and pointer controls. --List Input - simply place variable names in the INPUT statement and at least one space between each value in the data lines. (while it may not appear so, this type of input places restrictions on your data) input name $ test1 test2 test3; (See Program SAS_Lec#1_input_01.sas) --Column Input - reads the same data variable from the exact