stat #3 exam

out= option

we can use the out= option with most proc to keep output/results in a sas data set

the out= option is added to different procs

in different ways

out= in proc freq

in proc freq the out= option goes on the same line as the table statement:
proc freq data=sasdata.hotdogs;
table calories / out=myout1;
run;

out= in proc sort

in proc sort the out=option goes on the same line with proc sort:
proc sort data=sasdata.hotdogs out=myout2;
by calories;
run;

out= in proc means

in proc means the out= option goes in an output statement:
proc means data=sasdata.hotdogs;
output out=myout3;
run;

proc means

*useful for producing the everyday common statistics or one sample tests
�doesn't provide excess output (much less than proc univariate)
�by default it gives: mean, # of non-missing observations, stdev, min, and max
�univariate is the alternative to this

in proc means if you want descriptive statistics for certain groups

you can use a class statement (as an alternative to a by statement)
advantages to using a class statement: nicer looking output and you do not need to use a proc sort if you use a class statement

in proc means if additional statistics are requested

they must be specified
example: min, max, n
you put these on the proc means line

in proc means the default significance (alpha) level is

0.05 which is associated with a 95% confidence interval

**
look at sas code example on page #2
**

**
look at sas code example on page #2
**

is the out= option in proc transpose similar to the out= option in proc freq, proc sort, or proc means??

the out= option is on the same line as proc transpose so it is most similar to proc sort

proc univariate

displays a lot of descriptive statistics and has a lot of output

in proc univariate you can use

a class statement (no sorting required) as an alternative to a by statement (must proc sort first)

proc ttest

�can be used for a one- or tw-sample test
�can be used on independent as well as paired scenarios
�univariate and means were used for the one sample test with 0 as a null value
�options for test include: confidence limits and a null value other than 0

in proc ttest a class statement is the variable that

divides the data into two groups -> must be used for a 2-sample test

in proc ttest paired statement is for paired ttests

you cannot use class or var statements with the paired option -> you could also just make a new variable for the difference and then you do not even need to use the paired statement

**
look at sas code example on page #3
**

**
look at sas code example on page #3
**

example of a pvalue conclusion

we have sufficient evidence that the population mean _ is different than _
is pvalue is below 0.05
we would never run a hypothesis test on a sample because we have all of the sample data already

df

df = n - 1

proc anova is used for

analysis of variances

what are the null and alternative hypotheses for anova??

ho: u1=u2=u3=...=uk
ha: at least one u is different

proc anova is designed for

balanced data -> this is data where there are equal numbers of observations in each combination of the classified factor
n1=n2=n3

if you have an unbalanced design with more than one factor/treatment then

proc glm is better than proc anova

proc anova has two required statements

class and model
and class must come before model

the class statement in proc anova

specifies the classification (categorical) variables

the model statement in proc anova

specifies the response of interest

can you have an f value below 0??

no

definition of correlation

the strength and direction of the linear relationship between two variables

the true correlation

p rho

correlation ho and ha

ho: p=0
ha: p does not =0

will you ever know rho??

no

proc reg is used for

linear regression

proc reg has a required

model statement
always in this form:
model responsevar = listexplanatoryvars;

if you leave out the solutions option in proc glm

you will not see parameter estimates for the model

in proc glm

you need class and model

sas procedures do not produce output

they produce data

in sas9.4 the default output destination is

html
in 9.2 and before it was listing

name some ods destinations

html
listings
pdf
ps
rtf
markup
output

style= option

ods html close;
ods html style=ocean;
requests ocean style

ods trace

tells sas to print information about the output objects in the sas log

ods select

pull out the portion of output that you need (and leave out the stuff that you don't need)

code for ods select

ods select testsforlocation;
proc univariate data=_;
var=_;
run;

ods exclude

tell sas that there are portions of the output that you don't need

ods trace should be

turned on/off
proc contents data=
var age;
sasdata.popular
run;
ODS TRACE ON;
proc univariate data=sasdata.popular normal;
run;
ODS TRACE OFF;

general syntax ods html

ODS HTML FILE = 'body-filename.html' options;
code for which you want the HTML file to be generated for
ODS HTML CLOSE;
example sas code:
ODS HTML FILE='C:\Documents and
Settings\kdoehler\Desktop\Notes8_Ex_5a.html' style=ocean;
proc print data=sasdata.pop

general syntax rtf
rich text format

ODS RTF FILE = 'filename.rtf' options;Code for which you want the output to be saved as .RTF
ODS RTF CLOSE;

general syntax pdf
potable document format

ODS PDF FILE = 'filename.pdf' options;
Code for which you want the output to be saved as .PDF
ODS PDF CLOSE;

what are sas macros??

macros are simply a group of sas statements that have a name. and, anytime you want that group of statements in your program, you use the name instead of the re-typing all the statements

why are macros useful??

1. you can make one small change that will be universal throughout your program
2. macros allow you to write a piece/block of code once and use it over and over on the same or different programs
3. you can make programs that are data driven, letting sas d

to invoke a macro you use

%macroname;
the ; is optional

characteristics of macro variables

�they have a single value and do not belong to a data set
�they can be global (can be used anywhere in a sas program) or local (used only inside a macro)
�when sas encounters the name of a macro variable, the macro processor simply replaces the name with

the macro processor doesn't look for macro-variables inside single quotation marks

instead use double quotation marks when the macro variable will be use in a quoted string

macro general syntax

%MACRO macroName;
macroText
%MEND macroName;

macro arguments general syntax

%MACRO macroName (parameter1 , parameter2 , ...);
macroText
%MEND macroName;
inside a macro, you would write &parameter1. and &parameter2.
to invoke a macro with arguments of interest, you simply write the values for these arguments of
interest in parenth

macro commenting

/
u should use this kind
/
know this !!! maybe using * blah ; will be an error on the exam -> can cause a problem inside macros and can sometimes leads to unexpected results

conditional logic general syntax
two options

%IF condition %THEN action;
%ELSE %IF condition %THEN action;
%ELSE action;
%IF condition %THEN %DO;
SAS statements
%END;

if all of the IF, THEN, and DO statements are within the data step

then we do not need the % before the if, then, and do statements

call symput

takes a value from a data step and assigns it to a macro variable

you cannot create a macro variable with CALL SYMPUT and use it in the same DATA step

this is because SAS does not assign a value to the macro variable until the DATA step executes

video notes about call symput

we can't use a %let to create the macro variable is because we do not know the value of the variable - we have not looked at any output

proc ttest data=homeprice H):250000;
var price;
run;

ho: u=250000
ha: u no= 250000

proc ttest data=homeprice sides=u;
var price;
run;

ho: u=0
ha: u>0
if sides=L then ha: u<0

proc ttest data=sasdata.homeprice;
var price;
class corner;
run;

ho: u1-u2=0
ha: u1-u2 no= 0