


Study with the several resources on Docsity
Earn points by helping other students or get them with a premium plan
This page cannot be seen from the preview
Don't miss anything!



To open SAS in AgSci 119: Start → Programs → Reserve → SAS → SAS 9.
SAS is a software package used by many companies and researchers. We will focus in this course on the statistical tools available in SAS. This document will give you a quick crash course in some of the basics of SAS operation. SAS has four main windows:
To “run” a SAS program (or a highlighted section of SAS code), click on the “running man” icon, or hit F8.
Read in Data:
1 2 1 4 2 3 3 2
SAS code
data a1; infile ’C:\folder\datafile.txt’; input x y; run;
Necessary components to run a program:
Mathematical Operators: Function Operator Example addition + x+y subtraction - x-y multiplication * xy division / x/y power ** or ^ x* log log log(x) exponential exp exp(x)
Logical Operator Example equal = or eq if x = 1 unequal <> or ne if x <> 1 less than < or lt if x < 1 less than or equal to <= or le if x <= 1 greater than > or gt if x > 1 greater than or equal to >= or ge if x >= 1
Sample SAS code to create and view a new data set:
data a2; set a1; xy = xy; xsq = x*2; xeq1 = 0; if x = 1 then xeq1=1; run; proc print data=a2; var x y xeq1 xy xsq; title1 ’New Data Set’; run;
New Data Set
Obs x y xeq1 xy xsq
Sample SAS code to only keep certain observations in a new data set:
data a3; set a2; if y < 3.5; /* Default ’then’ is keep / run; / Same as: */ data a3; set a2; if y >= 3.5 then delete; run; proc print data=a3; var x y xeq1; title1 ’Smaller Set’; run;
Smaller Set
Obs x y xeq
Miscellaneous SAS Notes
options ls=80 nodate pageno=1 formdlim="~";
data a1; input x y z $ @@; cards; 1 2 alpha 1 4. 2 3 gamma 3. delta ; run; proc print data=a1;
proc means data=a1; var y; title1 "Means Output"; run; */
proc print data=a1; var y x z; title2 "Subtitle"; run;
Data Set 1
Obs x y z
1 1 2 alpha 2 1 4 3 2 3 gamma 4 3. delta
Data Set 2 Subtitle
Obs y x z
1 2 1 alpha 2 4 1 3 3 2 gamma