13K views

Uploaded by SASTechies

Learning
Base SAS,
Advanced SAS,
Proc SQl,
ODS,
SAS in financial industry,
Clinical trials,
SAS Macros,
SAS BI,
SAS on Unix,
SAS on Mainframe,
SAS interview Questions and Answers
SAS Tips and Techniques
SAS Resources
visit http://sastechies.blogspot.com

save

- SAS Slides 5 : Functions
- SAS Interview Questions and Answers 1
- SAS Slides 15 : Improving Effeciency With options in SAS
- SAS Slides 10 : ODS HTML
- SAS Slides 11 : Utility Procedures
- SAS Slides 14 : SAS Access / SAS Connect
- SAS Slides 3 : Understanding SAS Data Step Processing
- Learn SAS Programming
- SAS Slides 6 : Arrays
- SAS Slides 1 : Introduction to SAS
- SAS Slides 7 : Match Merging with Datastep
- SAS Slides 12 : Macros
- SAS Slides 9 : Plots and Graphs
- SAS Slides 8 : BASE SAS Statistics Procedures
- SAS Slides 4 : Reading Fixed and Varying Data
- Learn SAS programming : SAS video tutorials, SAS ebooks, SAS tutorials, SAS tips and Techniques, Base SAS and Advanced SAS certification, CDISC, SDTM, CRfs Annotation, ADAM, define.PDF, DEFINE.xml, SAS intervie Questions and answers, SAS macros, Proc SQL codes, SAS syntax,
- LEARN SAS within 7 weeks: Part4 (More on Manipulating Data)
- SAS Macro Examples
- An Introduction to the SAS System
- Sas Debugging Sas Programs
- SAS Interview questions and answers
- LEARN SAS within 7 weeks: Part2 (Introduction to SAS – The Data Step)
- 24599909 Learn SAS Programming
- LEARN SAS within 7 weeks: Part1
- Advanced SAS Programming Techniques (www.studysas.blogspot.com)
- SAS Programming Skills
- LEARN SAS within 7 weeks: Part5 (Procedures to Summarize Data)
- SAS Interview Questions
- LEARN SAS within 7 weeks: Part6 (Producing Graphics and Using SAS Analyst)
- Business Analytics Using SAS
- SAS Macro to Split a Macro Variables Values to Multiple Macro Variables Values and Also Get the Split Count Into Another Variable
- SAS Macro to Create a Delimited Text File From a SAS Dataset
- SAS Macro to Split a Dataset Into Multiple Datasets Vertically With a Common Primary Key
- SAS Macro Examples
- SAS Macro to Create Delete a Directory
- SAS Macro to Fill Missing Values in a Dataset With Specified Values for Numeric and Character Values
- Use SAS Function Propcase
- Basic Notes on Clinical Trials Phase I-IV
- Learn SAS Programming
- SAS Macro to Reorder Dataset Variables in Alphabetic Order
- SAS Macro That Reads the Filenames Available at a Particular Directory on Any FTP Server
- SAS Macro to Split Dataset by the Number of Observations Specified
- SAS Slides 14 : SAS Access / SAS Connect
- SAS Slides 3 : Understanding SAS Data Step Processing
- SAS Slides 6 : Arrays
- SAS Slides 1 : Introduction to SAS
- SAS Slides 7 : Match Merging with Datastep
- SAS Slides 12 : Macros
- SAS Slides 9 : Plots and Graphs
- SAS Slides 8 : BASE SAS Statistics Procedures
- SAS Slides 4 : Reading Fixed and Varying Data
- avaya
- GVI Fiji Achievement Report February 2015 - Composting Toilet Solutions
- Oop
- Fenton88 the Numerical Solution of Steady Water Wave Problems
- sd
- CIA Hacking Tools
- Goa Public Health Act and Rules
- Manual Calefacción
- Vaisala-DM70_Datasheet
- Rational Rose Manual
- Critical Management Practices Influecing on Site Waste Minimization in Construction Projects
- Normalización Norma y Especificación
- 1215 Obra Gruesa
- HPE_Master_ASE_-_Advanced_Server_Solutions_Archite 274 Pages Epub 440 Pages PDF 549 Pages DOC
- Acoustics of Green Buildings
- Department of Chemical Engineering
- Curso en Apoyo al Programa de Formación Continua Mantenimiento
- Les Tableaux
- VLSI Fabrication Facility
- Dynamic Search Algorithm in Unstructured
- TI83-manual.pdf
- 3 Properties of Project Risks the Owner's Role in Project Risk Management the National Academies Press
- Implement Voip Network
- Addendum 1
- Cours Nombres Complexes
- CUESTIONARIO
- Presentacion_ACAF_Master_EPS_UAM.pdf
- Chemical Synthesis of Complex Molecules Using Nano Particle
- 2.-Guía-rapida-gestión-de-proyectos
- Ficha de Evaluación Infografía

You are on page 1of 25

info@sastechies.com

http://www.sastechies.com

DATA steps typically create or modify SAS data sets, but they can also be

used to produce custom-designed reports. For example, you can use DATA

steps to

**◦ put your data into a SAS data set
**

◦ compute the values for new variables

◦ check for and correct errors in your data

◦ produce new SAS data sets by sub-setting, merging, and updating existing data

sets.

** PROC (procedure) steps typically analyze and process data in the form
**

of a SAS data set, and they sometimes create SAS data sets that contain

the results of the procedure. PROC steps control a library of prewritten

routines (procedures) that perform tasks on SAS data sets, such as listing,

sorting, and summarizing data. For example, you can use PROC steps to

◦ print a report

◦ produce descriptive statistics

◦ create a tabular report

◦ produce plots and charts.

**SAS Techies 2009 11/13/09 2
**

Data numbers; Start of a Datastep

X1=1; Assigning values to x1

x2=2; x2

Run; End the datastep

**Proc print Issue a Print Procedure
**

data=numbers; to print the dataset

numbers

Run;

End the Run statement

**SAS Techies 2009 11/13/09 3
**

C, C++, Java like syntax

Every Statement ends with ;

Datastep starts with the keyword data followed

by the dataset name.

Datastep ends when run; is found or any other

Data or Proc is found else the Status on the

window would show “Datastep or Proc Running”

It usually begins with a SAS keyword

they can begin and end anywhere on a line

one statement can continue over several lines

several statements can be on a line.

**SAS Techies 2009 11/13/09 4
**

Log would show the entire program with the

Run time i.e. Real time and the CPU Time.

** Any errors or any output with PUT or Macro
**

statements

**SAS Techies 2009 11/13/09 5
**

Output Window would show the output of the

Procedure in a Listing or HTML Format, date,

time and SAS System message.

** Results Window would show any results
**

produced

** Explorer window would show any dataset
**

prepared in that step.

**SAS Techies 2009 11/13/09 6
**

To define a library, you assign it a

library name and specify a path

Libname libref “C:\temp”;

Open the library in Explorer would

show all

◦ Datasets

◦ Catalogs

◦ macro compilation

◦ views

When you delete a library you

delete the reference to SAS engine

and Not the Contents at that path.

To delete the contents select all of

them and delete.

Note: libref is 1 to 8 characters

long only and remain in effect until

you modify them, cancel them, or

end your SAS session

**SAS Techies 2009 11/13/09 7
**

SAS file in any library except Work indicates that the SAS file is stored permanently

Permanent

SAS Files

Clinic . Admit Clinic . Admit2

Temporary

SAS File Temporary

SAS File,

One-Level

Name

Work . Test Test

**SAS Techies 2009 11/13/09 8
**

Datalines / cards statement

-- Indicates that data lines follow

**SAS Techies 2009 11/13/09 9
**

Set Statement

--Reads an observation from one or more already existing SAS data

sets

-- used to copy / subset of observations to perform additional

operations.

Data work.ins;

set clinic.insure(where=(weight>150));

if weight > 150 then Overweight=‘Yes’; run;

**SAS Techies 2009 11/13/09 10
**

a SAS data set is a file consisting of two

parts: a descriptor portion and a data

portion Data Set Name:

Member Type:

CLINIC.INSURE

DATA

Engine: V8

Created: 10:05 Tuesday,

March 30, 1999

Observations: 21

Variables: 7

Indexes: 0

Observation Length: 64

Name Sex Age Weight

** Jones M 48 128.6
**

Laverne M 58 158.3

** Jaffe F . 115.5
**

Wilson M 28 170.1

**SAS Techies 2009 11/13/09 11
**

Name Type Length Format Informat Label

------ ---- ----- --------- -------- -------------

Policy Num 8 Policy Number

Total Num 8 DOLLAR8.2 COMMA10. Total Balance

Name Char 20 Patient Name

**Variable names must ----
**

•be 1 to 32 characters in length

•begin with a letter (A-Z, including mixed case characters) or

an underscore (_)

•continue with any combination of numbers, letters, or

underscores.

A variable's type is either character or numeric.

**SAS Techies 2009 11/13/09 12
**

Description Default Length Max Length

Variable Name <32 32 characters

Value

CHAR 8 bytes 32767 (32Kb)

NUM 8 bytes any bytes

**SAS Techies 2009 11/13/09 13
**

Variable Type and Missing Values

**A variable's type determines how SAS software displays missing values for a
**

variable.

For character variables such as Name (shown below), a blank represents a missing

value.

For numeric variables such as Age (shown below), a period represents a missing value.

**Missing Name Sex Age Weight
**

values

M 48 128.6

Laverne M 58 158.3

** Jaffe F . 115.5
**

Wilson M 28 170.1

**SAS Techies 2009 11/13/09 14
**

Informats Informats determine how data values are

read into a SAS data set. You must use informats to

read numeric values that contain letters or other special

characters.

**$ASCIIw. DATEw. NENGOw.
**

$BINARYw. DATETIMEw. PDw.d

$VARYINGw. HEXw. PERCENTw.

$w. JULIANw. TIMEw.

COMMAw.d MMDDYYw. w.d

**SAS Techies 2009 11/13/09 15
**

Formats write values out using some particular form.

** User defined formats
**

proc format lib=library;

value JobFmt * if format is char then $Jobfmt ;

103='manager'

105='text processor‘;

run;

Applied like -- format var Jobfmt. Var2 dollar11.2;

These are utilized to look up as if it were a table.

**SAS Techies 2009 11/13/09 16
**

Contents Procedure

PROC CONTENTS DATA=libref._ALL_

NODETAILS;

RUN;

**SAS Techies 2009 11/13/09 17
**

To modify system PROC OPTIONS <option(s)>;

options, you submit RUN;

an OPTIONS Proc options option=firstobs value; run;

statement.

Number|NoNumber BYLINE|NOBYLINE

OPTIONS statement Date|nodate DETAILS|NODETAILS

is global, the Pageno FIRSTOBS=

FORMCHAR=

settings remain in Pagesize FORMDLIM=

effect until you Linesize LABEL|NOLABEL

modify them or end Mprint OBS=

your SAS session. Mlogic REPLACE|NOREPLACE

SOURCE|NOSOURCE

Symbolgen

Compress=yes|no

**SAS Techies 2009 11/13/09 18
**

Default Yearcutoff=1920

Date Expression Interpreted As

12/07/41 12/07/1941

18Dec15 18Dec2015

04/15/30 04/15/1930

15Apr95 15Apr1995

**Date Expression SAS Date Informat Interpreted As
**

06Oct59 date7. 06Oct1959

17Mar1783 date9. 17Mar1783

**SAS Techies 2009 11/13/09 19
**

Assignment statements

X1=1; X2=2; X3=X2-X1;

Note: In the second case if either X2 or X1 is

missing then the value of X3 is missing.

** You can create a variable (not macro
**

variables) in a Datastep only.

Ex: data new; x=‘abc’; run;

**SAS Techies 2009 11/13/09 20
**

To create a variable that accumulates values

down observations, a sum statement in a

DATA step is used.

Note -- missing values are ignored.

Equivalent to function Sum(x1,x2,….)

**Ex: If dsn some has y values
**

Data new; Y - 10,20,30 then

set some;

X+y; X - 10,30,60

run;

**SAS Techies 2009 11/13/09 21
**

To assign a length to a variable

Ex: Length var1 $ 10 var2 10;

Where used:

**data finance.newloan;
**

set finance.records(drop=amount rate);

TotalLoan+payment;

if code='1' then Type='Fixed';

else Type='Variable'; run;

Output will have Type=‘Varia’

**SAS Techies 2009 11/13/09 22
**

Error Types

**◦ Syntax Errors - occur when program statements do not
**

conform to the rules of the SAS language

◦ Data Errors - occur when some data values are not appropriate for the SAS

statements that are specified in a program

**SAS Techies 2009 11/13/09 23
**

SAS Techies 2009 11/13/09 24

NOTE: Invalid data for RecHR in line 14 35-37.

RULE: ----+----1----+----2----+----3----+----4----+----5---

14 2575 Quigley, M 74 152 Q13 11 26 I

**ID=2575 Name=Quigley, M RestHR=74 MaxHR=152 RecHR=. TimeMin=11
**

TimeSec=26 Tolerance=I _ERROR_=1 _N_=14

**NOTE: 21 records were read from the infile TESTS.
**

The minimum record length was 45.

The maximum record length was 45.

NOTE: The data set CLINIC.STRESS has 21 observations and 8 variables.

NOTE: DATA statement used: real time 2.04 seconds cpu time 0.06

seconds

SAS Techies 2009 11/13/09 25

- SAS Slides 5 : FunctionsUploaded bySASTechies
- SAS Interview Questions and Answers 1Uploaded bySASTechies
- SAS Slides 15 : Improving Effeciency With options in SASUploaded bySASTechies
- SAS Slides 10 : ODS HTMLUploaded bySASTechies
- SAS Slides 11 : Utility ProceduresUploaded bySASTechies
- SAS Slides 14 : SAS Access / SAS ConnectUploaded bySASTechies
- SAS Slides 3 : Understanding SAS Data Step ProcessingUploaded bySASTechies
- Learn SAS ProgrammingUploaded bySASTechies
- SAS Slides 6 : ArraysUploaded bySASTechies
- SAS Slides 1 : Introduction to SASUploaded bySASTechies
- SAS Slides 7 : Match Merging with DatastepUploaded bySASTechies
- SAS Slides 12 : MacrosUploaded bySASTechies
- SAS Slides 9 : Plots and GraphsUploaded bySASTechies
- SAS Slides 8 : BASE SAS Statistics ProceduresUploaded bySASTechies
- SAS Slides 4 : Reading Fixed and Varying DataUploaded bySASTechies
- Learn SAS programming : SAS video tutorials, SAS ebooks, SAS tutorials, SAS tips and Techniques, Base SAS and Advanced SAS certification, CDISC, SDTM, CRfs Annotation, ADAM, define.PDF, DEFINE.xml, SAS intervie Questions and answers, SAS macros, Proc SQL codes, SAS syntax,Uploaded bysarath.annapareddy
- LEARN SAS within 7 weeks: Part4 (More on Manipulating Data)Uploaded bysarath.annapareddy
- SAS Macro ExamplesUploaded bySASTechies
- An Introduction to the SAS SystemUploaded byharshad_scribd
- Sas Debugging Sas ProgramsUploaded byΓιάννης
- SAS Interview questions and answersUploaded bysarath.annapareddy
- LEARN SAS within 7 weeks: Part2 (Introduction to SAS – The Data Step)Uploaded bysarath.annapareddy
- 24599909 Learn SAS ProgrammingUploaded bySheena Thakur
- LEARN SAS within 7 weeks: Part1Uploaded bysarath.annapareddy
- Advanced SAS Programming Techniques (www.studysas.blogspot.com)Uploaded bysarath.annapareddy
- SAS Programming SkillsUploaded bystevensap
- LEARN SAS within 7 weeks: Part5 (Procedures to Summarize Data)Uploaded bysarath.annapareddy
- SAS Interview QuestionsUploaded byapi-3840832
- LEARN SAS within 7 weeks: Part6 (Producing Graphics and Using SAS Analyst)Uploaded bysarath.annapareddy
- Business Analytics Using SASUploaded bysujit9

- SAS Macro to Split a Macro Variables Values to Multiple Macro Variables Values and Also Get the Split Count Into Another VariableUploaded bySASTechies
- SAS Macro to Create a Delimited Text File From a SAS DatasetUploaded bySASTechies
- SAS Macro to Split a Dataset Into Multiple Datasets Vertically With a Common Primary KeyUploaded bySASTechies
- SAS Macro ExamplesUploaded bySASTechies
- SAS Macro to Create Delete a DirectoryUploaded bySASTechies
- SAS Macro to Fill Missing Values in a Dataset With Specified Values for Numeric and Character ValuesUploaded bySASTechies
- Use SAS Function PropcaseUploaded bySASTechies
- Basic Notes on Clinical Trials Phase I-IVUploaded bySASTechies
- Learn SAS ProgrammingUploaded bySASTechies
- SAS Macro to Reorder Dataset Variables in Alphabetic OrderUploaded bySASTechies
- SAS Macro That Reads the Filenames Available at a Particular Directory on Any FTP ServerUploaded bySASTechies
- SAS Macro to Split Dataset by the Number of Observations SpecifiedUploaded bySASTechies
- SAS Slides 14 : SAS Access / SAS ConnectUploaded bySASTechies
- SAS Slides 3 : Understanding SAS Data Step ProcessingUploaded bySASTechies
- SAS Slides 6 : ArraysUploaded bySASTechies
- SAS Slides 1 : Introduction to SASUploaded bySASTechies
- SAS Slides 7 : Match Merging with DatastepUploaded bySASTechies
- SAS Slides 12 : MacrosUploaded bySASTechies
- SAS Slides 9 : Plots and GraphsUploaded bySASTechies
- SAS Slides 8 : BASE SAS Statistics ProceduresUploaded bySASTechies
- SAS Slides 4 : Reading Fixed and Varying DataUploaded bySASTechies

- avayaUploaded byJuan Jose Perez
- GVI Fiji Achievement Report February 2015 - Composting Toilet SolutionsUploaded byGlobal Vision International Fiji
- OopUploaded byDocumentation Junkie
- Fenton88 the Numerical Solution of Steady Water Wave ProblemsUploaded byjobinhoeljoven
- sdUploaded byAlfredo Caballero
- CIA Hacking ToolsUploaded bycrazybear
- Goa Public Health Act and RulesUploaded bykuttra
- Manual CalefacciónUploaded byRubén Moralejo
- Vaisala-DM70_DatasheetUploaded byyannick.pratte8709
- Rational Rose ManualUploaded byVivy Fon
- Critical Management Practices Influecing on Site Waste Minimization in Construction ProjectsUploaded byjcaldanab
- Normalización Norma y EspecificaciónUploaded byOmar
- 1215 Obra GruesaUploaded bynelly_hermosilla3937
- HPE_Master_ASE_-_Advanced_Server_Solutions_Archite 274 Pages Epub 440 Pages PDF 549 Pages DOCUploaded byChua Hian Koon
- Acoustics of Green BuildingsUploaded bymuehleisen
- Department of Chemical EngineeringUploaded byAsiphe Es-Tee Mdlokovane
- Curso en Apoyo al Programa de Formación Continua MantenimientoUploaded byXavi E Medina
- Les TableauxUploaded byelectrodi
- VLSI Fabrication FacilityUploaded bySriram
- Dynamic Search Algorithm in UnstructuredUploaded byarunavangala
- TI83-manual.pdfUploaded byKirvy Chén
- 3 Properties of Project Risks the Owner's Role in Project Risk Management the National Academies PressUploaded byMaestria Unan
- Implement Voip NetworkUploaded byqillisse
- Addendum 1Uploaded bystretch317
- Cours Nombres ComplexesUploaded byFarid Afifi
- CUESTIONARIOUploaded byNelly Eliza Fonseca
- Presentacion_ACAF_Master_EPS_UAM.pdfUploaded bydayern33
- Chemical Synthesis of Complex Molecules Using Nano ParticleUploaded byJiufeng Fan
- 2.-Guía-rapida-gestión-de-proyectosUploaded byGibrant Mac
- Ficha de Evaluación InfografíaUploaded byCYBERAUQUIS