0% found this document useful (0 votes)
111 views2 pages

SAS Syntax Handout 1

SAS Syntax Handout Commands

Uploaded by

Slijpsel
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
111 views2 pages

SAS Syntax Handout 1

SAS Syntax Handout Commands

Uploaded by

Slijpsel
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 2

Examining SAS Data Set Descriptor Portion Augmenting a WHERE Statement

PROC CONTENTS DATA=SAS-data-set; WHERE expression1;


RUN; WHERE SAME AND expression2;
WHERE ALSO expression3;

Examining SAS Data Set Data Portion


Labels
PROC PRINT DATA=SAS-data-set;
RUN; LABEL variable1='label1'
variable2='label2' …;

SAS LIBNAME Statement


Titles and Footnotes
LIBNAME libref 'SAS-data-library' <options>;
LIBNAME libref CLEAR; TITLEn 'text';
TITLE;

Browsing a SAS Library FOOTNOTEn 'text';


FOOTNOTE;
PROC CONTENTS DATA=libref._ALL_ <NODS>;
RUN;
Applying Formats

Sorting Data FORMAT variable(s) format …;

PROC SORT DATA=input-SAS-data-set


<OUT=output-SAS-data-set>; Creating User-Defined Formats
BY <DESCENDING> BY-variables;
RUN; PROC FORMAT;
VALUE <$>format-name range1='labe1l'
range2='label2'
Producing Detail Reports …;
RUN;
PROC PRINT DATA=SAS-data-set
<NOOBS LABEL SPLIT='split-character'>;
VAR variable(s); Reading a SAS Data Set
SUM variable(s);
BY variable(s); DATA output-SAS-data-set(s);
ID variable(s); SET input-SAS-data-set;
RUN; <additional SAS statements>
RUN;

Subsetting Observations
Creating New Variables
WHERE expression;
new-variable=expression;

IF expression;
LENGTH variable(s) <$> length …;

Special WHERE Operators


Subsetting Variables
BETWEEN-AND
? or CONTAINS DROP variable-list;
IS NULL or IS MISSING
LIKE
KEEP variable-list;

SAS and all other SAS Institute Inc. product or service names are registered trademarks or trademarks of SAS Institute Inc.
in the USA and other countries. ® indicates USA registration. Other brand and product names are trademarks of their
respective companies. Copyright © 2015 SAS Institute Inc. Cary, NC, USA. All rights reserved.
Reading Spreadsheet Data Conditional Processing

LIBNAME libref <engine-name> IF expression THEN statement;


<PATH=>'physical-filename' <options>; ELSE IF expression THEN statement;
LIBNAME libref CLEAR; ELSE statement;

Reading Database Data IF expression THEN DO;


statements
LIBNAME libref engine-name <SAS/ACCESS options>; END;
LIBNAME libref CLEAR; ELSE IF expression THEN DO;
statements
END;
Creating and Using Macro Variables ELSE DO;
statements
END;
%LET macro-variable=value;
&macro-variable
SAS Data Set Options
Reading Delimited Raw Data Files
SAS-data-set(IN=variable)
DATA SAS-data-set(s);
INFILE 'filename' <DLM='delimiter'>
<DSD> <MISSOVER>; SAS-data-set(RENAME=(old-name1=new-name1
INPUT variable <$> variable <:informat>… ; old-name2=new-name2…))
<additional SAS statements>
RUN;
Data Summarization and Validation
Procedures
Concatenating SAS Data Sets
PROC MEANS DATA=SAS-data-set <options statistics>;
DATA SAS-data-set(s); CLASS variable(s);
SET SAS-data-sets; VAR variable(s);
<additional SAS statements> RUN;
RUN;

Merging SAS Data Sets PROC FREQ DATA=SAS-data-set <options>;


TABLES variable(s) </ option(s)>;
TABLES variable1* variable2 </ option(s)>;
DATA SAS-data-sets; RUN;
MERGE SAS-data-sets;
BY <DESCENDING> BY-variable(s);
<additional SAS statements>
RUN; PROC UNIVARIATE DATA=SAS-data-set;
VAR variable(s);
ID variable(s);
Functions RUN;

YEAR(SAS-date)
QTR(SAS-date) Directing Output to External Files
MONTH(SAS-date)
DAY(SAS-date) ODS destination FILE='[Link]'
WEEKDAY(SAS-date) <STYLE=style-template>;
TODAY() or DATE() SAS code generating output
MDY(month, day, year) ODS destination CLOSE;
UPCASE(argument)
SUM(argument1,argument2, . . .)

SAS and all other SAS Institute Inc. product or service names are registered trademarks or trademarks of SAS Institute Inc.
in the USA and other countries. ® indicates USA registration. Other brand and product names are trademarks of their
respective companies. Copyright © 2015 SAS Institute Inc. Cary, NC, USA. All rights reserved.

You might also like