SlideShare a Scribd company logo
1 of 31
BAS 150
Lesson 4: Creating and Managing SAS Datasets
& Formats and Labels
• Create a permanent SAS data set
• Effectively manage multiple SAS data sets and libraries
• Modify SAS data sets
• Evaluate the difference in data formats and labels
• Create a new variable in SAS using formats
This Lesson’s Learning Objectives
SAS Data Sets
 SAS datasets can be permanent or temporary.
 Previously, we’ve used the data statement to create
temporary SAS datasets.
 In this lesson, we’ll learn how to create permanent SAS
datasets using the data statement.
 They are subdirectories or folders
 They store SAS datasets
 Starts with libname statement
Understanding SAS Libraries (1 of 3)
 Libref is the location name you give for the subdirectory
where SAS needs to look for the dataset
 You will refer to this libref further in your programs
 The libref for this libname statement is:
Understanding SAS Libraries (2 of 3)
 Libref
o Naming Rules
 8 characters or less
 Begin with character or underscore
 No special characters or spaces
o If you do not specify a libref…
 Temporary save to work library
Understanding SAS Libraries (3 of 3)
Creating a Permanent SAS Dataset
 Two parts
o Descriptor
o Data
 PROC Statements
o PROC Print
o PROC Contents
Format of SAS Datasets
PROC Contents (1 of 2)
PROC Contents can be used to
display the metadata, or descriptor
portion, of the SAS dataset.
PROC Contents (2 of 2)
Note the key parts:
• Data set name
• File name
• Number of variables
• Number of
observations
• Variable list
Proc contents is an easy
way to know what’s in
your dataset
PROC Contents: VARNUM Option
 By default, all variables in the PROC contents procedure
are listed alphabetically
 Sometimes, it is useful to look at the variable list in the
order they were created
 This can be done using the VARNUM option.
Before: After:
 Useful for showing your results of your code
 However, doing a default proc print option with a large dataset will
generate endless pages of output and can even make SAS freeze.
 It’s better to specify options when using PROC Print, which we’ll
discuss next.
PROC Print
 There are several options for Proc Print:
o Var – specifies the variables you want to print
o Noobs – suppresses the default observation column
o Obs – limits the number of observations
PROC Print Options
Importing a SAS Data Set
 Soccer is the Library
 Soccer_Scores is the
dataset within the library.
 No need for infile
statements to retrieve
data.
 The set statement is like an
input statement, but instead
of reading in a raw data file,
it reads observations from a
SAS dataset.
Modifying a SAS Data Set
There are many different ways to
modify a SAS data set.
The example on the left uses the
“Where” statement to subset the
work.goals data set AND creates a
new SAS data set called
work.topgoals.
Work.topgoals only includes
observations where the goal
variable is greater than or equal to
10 goals.
Formats and Labels
 Label Statement
 Apply in DATA or PROC step
o DATA or PROC Datasets: permanent
o PROC steps: temporary
Using Labels (1 of 3)
Using Labels (2 of 3)
• The first label statement is in the data
statement.
• It creates permanent descriptors for the
variables player, goals, age and
years_playing
• The second label statement is in the
proc print statement.
• Proc Print requires a label option
when you want to display labels
(instead of field names) in the column
header, because the default is the
variable name.
Using Labels (3 of 3)
• To the right is the output
using our label statement
• The headings are now the
labels, instead of variable
names.
 Similar to labels
 Define appearance of data
 Grouping
 Predefined or custom
 Both Data and Proc steps
o Data: Permanent
o Proc: Temporary
Formats
Format Rules
$ Indicates a character format.
format Names the SAS format.
w
Specifies the total format width, including decimal places and
special characters.
.
Is required syntax. Formats always contain a period (.)
as part of the name.
d
Specifies the number of decimal places to display in numeric
formats.
<$>format<w>.<d>
Commonly Used SAS Formats
Format Definition
$w. Writes standard character data.
w.d Writes standard numeric data.
COMMAw.d
Writes numeric values with a comma that separates every three digits and
a period that separates the decimal fraction.
DOLLARw.d
Writes numeric values with a leading dollar sign, a comma that separates
every three digits, and a period that separates the decimal fraction.
COMMAXw.d
Writes numeric values with a period that separates every three digits and a
comma that separates the decimal fraction.
EUROXw.d
Writes numeric values with a leading euro symbol (€), a period that
separates every three digits, and a comma that separates the decimal
fraction.
Pre-formatted value Format Formatted value
2125854 comma10. 2,125,854
52115 dollar14.2 $52,115.00
17526 mmddyy8. 12/26/07
17526 weekdate. Wednesday, December 26, 2007
M $Gender. Male
12 AgeGroup. Under 18
C $PassFail. Passing Grade
Examples of Formats
Format Names
Specifying Ranges of Values
Age of Player Value
5 - 6 Level 1
7-9 Level 2
10-12 Level 3
We can create our own formats to simplify
data presentation by creating groups.
From the Soccer data, we can create a
format for age so that each value
represents a “Playing Level”
Example: Soccer players that are 5 or 6
years old are considered a “Level 1”,
where those that are 7,8 or 9 are
considered “Level 2”
Defining a Numeric Format
Using PROC Format
We create a new format
called “level”.
This format will convert the
age variable into playing
levels 1 – 3.
Notice we do not reference
age at all in the proc
statement. Why? Because
a format can be used for
any variable.
Applying a Numeric Format
Once we’ve created the format, we
can use it in PROC PRINT
Notice the period at the end of the
second group of statements.
This is important and an easy
place to make an error!
Remember, there is no period
when you create the format, but
a period is required when you
use it.
Viewing the Output
Note: I changed the age variable
label to ‘Playing Level’ for
reporting purposes
Creating a New Variable in SAS
Instead of changing the variable
label name for age, we can create a
new variable called “Playing_Level”.
By using a PUT statement we can
combine the age variable and the
format level to create
“Playing_Level”.
The Output.
• Create a permanent SAS data set
• Effectively manage multiple SAS data sets and libraries
• Modify SAS data sets
• Evaluate the difference in data formats and labels
• Create a new variable in SAS using formats
Summary - Learning Objectives
“This workforce solution was funded by a grant awarded by the U.S. Department of Labor’s
Employment and Training Administration. The solution was created by the grantee and does not
necessarily reflect the official position of the U.S. Department of Labor. The Department of Labor
makes no guarantees, warranties, or assurances of any kind, express or implied, with respect to such
information, including any information on linked sites and including, but not limited to, accuracy of the
information or its completeness, timeliness, usefulness, adequacy, continued availability, or ownership.”
Except where otherwise stated, this work by Wake Technical Community College Building Capacity in
Business Analytics, a Department of Labor, TAACCCT funded project, is licensed under the Creative
Commons Attribution 4.0 International License. To view a copy of this license, visit
http://creativecommons.org/licenses/by/4.0/
Copyright Information

More Related Content

What's hot

Introduction To R Language
Introduction To R LanguageIntroduction To R Language
Introduction To R LanguageGaurang Dobariya
 
Relational data model
Relational data modelRelational data model
Relational data modelSURBHI SAROHA
 
2 data structure in R
2 data structure in R2 data structure in R
2 data structure in Rnaroranisha
 
Introduction to SAS
Introduction to SASIntroduction to SAS
Introduction to SASImam Jaffer
 
Intro to t sql – 3rd session
Intro to t sql – 3rd sessionIntro to t sql – 3rd session
Intro to t sql – 3rd sessionMedhat Dawoud
 
Intro To TSQL - Unit 5
Intro To TSQL - Unit 5Intro To TSQL - Unit 5
Intro To TSQL - Unit 5iccma
 
Introduction to-sas-1211594349119006-8
Introduction to-sas-1211594349119006-8Introduction to-sas-1211594349119006-8
Introduction to-sas-1211594349119006-8thotakoti
 
2005 fall cs523_lecture_4
2005 fall cs523_lecture_42005 fall cs523_lecture_4
2005 fall cs523_lecture_4abhineetverma
 
ALL ABOUT SQL AND RDBMS
ALL ABOUT SQL AND RDBMSALL ABOUT SQL AND RDBMS
ALL ABOUT SQL AND RDBMSgaurav koriya
 
Bc0038– data structure using c
Bc0038– data structure using cBc0038– data structure using c
Bc0038– data structure using chayerpa
 
Structure query language (sql)
Structure query language (sql)Structure query language (sql)
Structure query language (sql)Nalina Kumari
 
Introduction to SQL
Introduction to SQLIntroduction to SQL
Introduction to SQLMahir Haque
 

What's hot (20)

Introduction To R Language
Introduction To R LanguageIntroduction To R Language
Introduction To R Language
 
Sql ppt
Sql pptSql ppt
Sql ppt
 
Sql.pptx
Sql.pptxSql.pptx
Sql.pptx
 
Relational data model
Relational data modelRelational data model
Relational data model
 
2 data structure in R
2 data structure in R2 data structure in R
2 data structure in R
 
Introduction to SAS
Introduction to SASIntroduction to SAS
Introduction to SAS
 
Intro to t sql – 3rd session
Intro to t sql – 3rd sessionIntro to t sql – 3rd session
Intro to t sql – 3rd session
 
Sql Basics And Advanced
Sql Basics And AdvancedSql Basics And Advanced
Sql Basics And Advanced
 
Chapter2
Chapter2Chapter2
Chapter2
 
Sql fundamentals
Sql fundamentalsSql fundamentals
Sql fundamentals
 
6. R data structures
6. R data structures6. R data structures
6. R data structures
 
Exemplo arquivo arff
Exemplo arquivo arffExemplo arquivo arff
Exemplo arquivo arff
 
Arrays in c_language
Arrays in c_language Arrays in c_language
Arrays in c_language
 
Intro To TSQL - Unit 5
Intro To TSQL - Unit 5Intro To TSQL - Unit 5
Intro To TSQL - Unit 5
 
Introduction to-sas-1211594349119006-8
Introduction to-sas-1211594349119006-8Introduction to-sas-1211594349119006-8
Introduction to-sas-1211594349119006-8
 
2005 fall cs523_lecture_4
2005 fall cs523_lecture_42005 fall cs523_lecture_4
2005 fall cs523_lecture_4
 
ALL ABOUT SQL AND RDBMS
ALL ABOUT SQL AND RDBMSALL ABOUT SQL AND RDBMS
ALL ABOUT SQL AND RDBMS
 
Bc0038– data structure using c
Bc0038– data structure using cBc0038– data structure using c
Bc0038– data structure using c
 
Structure query language (sql)
Structure query language (sql)Structure query language (sql)
Structure query language (sql)
 
Introduction to SQL
Introduction to SQLIntroduction to SQL
Introduction to SQL
 

Viewers also liked

Where Vs If Statement
Where Vs If StatementWhere Vs If Statement
Where Vs If StatementSunil Gupta
 
BAS 150 Lesson 5 Lecture
BAS 150 Lesson 5 LectureBAS 150 Lesson 5 Lecture
BAS 150 Lesson 5 LectureWake Tech BAS
 
Learning SAS With Example by Ron Cody :Chapter 16 to Chapter 20 Solution
Learning SAS With Example by Ron Cody :Chapter 16 to Chapter 20 SolutionLearning SAS With Example by Ron Cody :Chapter 16 to Chapter 20 Solution
Learning SAS With Example by Ron Cody :Chapter 16 to Chapter 20 SolutionVibeesh CS
 
SAS Ron Cody Solutions for even Number problems from Chapter 7 to 15
SAS Ron Cody Solutions for even Number problems from Chapter 7 to 15SAS Ron Cody Solutions for even Number problems from Chapter 7 to 15
SAS Ron Cody Solutions for even Number problems from Chapter 7 to 15Ayapparaj SKS
 
SAS Ron Cody Solutions for even Number problems from Chapter 16 to 20
SAS Ron Cody Solutions for even Number problems from Chapter 16 to 20SAS Ron Cody Solutions for even Number problems from Chapter 16 to 20
SAS Ron Cody Solutions for even Number problems from Chapter 16 to 20Ayapparaj SKS
 
BAS 150 Lesson 2 Lecture
BAS 150 Lesson 2 Lecture BAS 150 Lesson 2 Lecture
BAS 150 Lesson 2 Lecture Wake Tech BAS
 

Viewers also liked (7)

Where Vs If Statement
Where Vs If StatementWhere Vs If Statement
Where Vs If Statement
 
BAS 150 Lesson 5 Lecture
BAS 150 Lesson 5 LectureBAS 150 Lesson 5 Lecture
BAS 150 Lesson 5 Lecture
 
Learning SAS With Example by Ron Cody :Chapter 16 to Chapter 20 Solution
Learning SAS With Example by Ron Cody :Chapter 16 to Chapter 20 SolutionLearning SAS With Example by Ron Cody :Chapter 16 to Chapter 20 Solution
Learning SAS With Example by Ron Cody :Chapter 16 to Chapter 20 Solution
 
SAS Ron Cody Solutions for even Number problems from Chapter 7 to 15
SAS Ron Cody Solutions for even Number problems from Chapter 7 to 15SAS Ron Cody Solutions for even Number problems from Chapter 7 to 15
SAS Ron Cody Solutions for even Number problems from Chapter 7 to 15
 
BAS 250 Lecture 5
BAS 250 Lecture 5BAS 250 Lecture 5
BAS 250 Lecture 5
 
SAS Ron Cody Solutions for even Number problems from Chapter 16 to 20
SAS Ron Cody Solutions for even Number problems from Chapter 16 to 20SAS Ron Cody Solutions for even Number problems from Chapter 16 to 20
SAS Ron Cody Solutions for even Number problems from Chapter 16 to 20
 
BAS 150 Lesson 2 Lecture
BAS 150 Lesson 2 Lecture BAS 150 Lesson 2 Lecture
BAS 150 Lesson 2 Lecture
 

Similar to BAS 150 Lesson 4 Lecture

Introduction to sas
Introduction to sasIntroduction to sas
Introduction to sasAjay Ohri
 
Basics Of SAS Programming Language
Basics Of SAS Programming LanguageBasics Of SAS Programming Language
Basics Of SAS Programming Languageguest2160992
 
Sample Questions The following sample questions are not in.docx
Sample Questions The following sample questions are not in.docxSample Questions The following sample questions are not in.docx
Sample Questions The following sample questions are not in.docxtodd331
 
BAS 150 Lesson 3 Lecture
BAS 150 Lesson 3 LectureBAS 150 Lesson 3 Lecture
BAS 150 Lesson 3 LectureWake Tech BAS
 
Acf data integration_workshop - he summit '17 template
Acf data integration_workshop - he summit '17 templateAcf data integration_workshop - he summit '17 template
Acf data integration_workshop - he summit '17 templateSalesforce.org
 
SAS Online Training Institute in Hyderabad - C-Point
SAS Online Training Institute in Hyderabad - C-PointSAS Online Training Institute in Hyderabad - C-Point
SAS Online Training Institute in Hyderabad - C-Pointcpointss
 
Sas Talk To R Users Group
Sas Talk To R Users GroupSas Talk To R Users Group
Sas Talk To R Users Groupgeorgette1200
 
Prog1 chap1 and chap 2
Prog1 chap1 and chap 2Prog1 chap1 and chap 2
Prog1 chap1 and chap 2rowensCap
 
Base and Advanced SAS Training Contents
Base and Advanced SAS Training ContentsBase and Advanced SAS Training Contents
Base and Advanced SAS Training ContentsGaurav Jain
 
Sas tips & tricks
Sas tips & tricksSas tips & tricks
Sas tips & tricksshanmukh28
 
Sas Enterprise Guide A Revolutionary Tool
Sas Enterprise Guide A Revolutionary ToolSas Enterprise Guide A Revolutionary Tool
Sas Enterprise Guide A Revolutionary Toolsysseminar
 
Sas training institute in marathahalli bangalore
Sas training institute in marathahalli bangaloreSas training institute in marathahalli bangalore
Sas training institute in marathahalli bangaloreBizsmart Solutions
 

Similar to BAS 150 Lesson 4 Lecture (20)

Introduction to sas
Introduction to sasIntroduction to sas
Introduction to sas
 
Stata tutorial university of princeton
Stata tutorial university of princetonStata tutorial university of princeton
Stata tutorial university of princeton
 
SAS - Training
SAS - Training SAS - Training
SAS - Training
 
Basics Of SAS Programming Language
Basics Of SAS Programming LanguageBasics Of SAS Programming Language
Basics Of SAS Programming Language
 
SAS Internal Training
SAS Internal TrainingSAS Internal Training
SAS Internal Training
 
Sample Questions The following sample questions are not in.docx
Sample Questions The following sample questions are not in.docxSample Questions The following sample questions are not in.docx
Sample Questions The following sample questions are not in.docx
 
SAS Online Training by Real Time Working Professionals in USA,UK,India,Middle...
SAS Online Training by Real Time Working Professionals in USA,UK,India,Middle...SAS Online Training by Real Time Working Professionals in USA,UK,India,Middle...
SAS Online Training by Real Time Working Professionals in USA,UK,India,Middle...
 
BAS 150 Lesson 3 Lecture
BAS 150 Lesson 3 LectureBAS 150 Lesson 3 Lecture
BAS 150 Lesson 3 Lecture
 
Sas training in hyderabad
Sas training in hyderabadSas training in hyderabad
Sas training in hyderabad
 
Acf data integration_workshop - he summit '17 template
Acf data integration_workshop - he summit '17 templateAcf data integration_workshop - he summit '17 template
Acf data integration_workshop - he summit '17 template
 
SAS Online Training Institute in Hyderabad - C-Point
SAS Online Training Institute in Hyderabad - C-PointSAS Online Training Institute in Hyderabad - C-Point
SAS Online Training Institute in Hyderabad - C-Point
 
Sas
SasSas
Sas
 
Spss basics tutorial
Spss basics tutorialSpss basics tutorial
Spss basics tutorial
 
Sas Talk To R Users Group
Sas Talk To R Users GroupSas Talk To R Users Group
Sas Talk To R Users Group
 
Prog1 chap1 and chap 2
Prog1 chap1 and chap 2Prog1 chap1 and chap 2
Prog1 chap1 and chap 2
 
Base and Advanced SAS Training Contents
Base and Advanced SAS Training ContentsBase and Advanced SAS Training Contents
Base and Advanced SAS Training Contents
 
Sas tips & tricks
Sas tips & tricksSas tips & tricks
Sas tips & tricks
 
Sas Enterprise Guide A Revolutionary Tool
Sas Enterprise Guide A Revolutionary ToolSas Enterprise Guide A Revolutionary Tool
Sas Enterprise Guide A Revolutionary Tool
 
SAS Defined Format.pptx
SAS Defined Format.pptxSAS Defined Format.pptx
SAS Defined Format.pptx
 
Sas training institute in marathahalli bangalore
Sas training institute in marathahalli bangaloreSas training institute in marathahalli bangalore
Sas training institute in marathahalli bangalore
 

More from Wake Tech BAS

More from Wake Tech BAS (8)

BAS 250 Lecture 8
BAS 250 Lecture 8BAS 250 Lecture 8
BAS 250 Lecture 8
 
BAS 250 Lecture 4
BAS 250 Lecture 4BAS 250 Lecture 4
BAS 250 Lecture 4
 
BAS 250 Lecture 3
BAS 250 Lecture 3BAS 250 Lecture 3
BAS 250 Lecture 3
 
BAS 250 Lecture 2
BAS 250 Lecture 2BAS 250 Lecture 2
BAS 250 Lecture 2
 
BAS 250 Lecture 1
BAS 250 Lecture 1BAS 250 Lecture 1
BAS 250 Lecture 1
 
BAS 150 Lesson 8 Lecture
BAS 150 Lesson 8 LectureBAS 150 Lesson 8 Lecture
BAS 150 Lesson 8 Lecture
 
BAS 150 Lesson 7 Lecture
BAS 150 Lesson 7 LectureBAS 150 Lesson 7 Lecture
BAS 150 Lesson 7 Lecture
 
BAS 150 Lesson 1 Lecture
BAS 150 Lesson 1 LectureBAS 150 Lesson 1 Lecture
BAS 150 Lesson 1 Lecture
 

Recently uploaded

Alper Gobel In Media Res Media Component
Alper Gobel In Media Res Media ComponentAlper Gobel In Media Res Media Component
Alper Gobel In Media Res Media ComponentInMediaRes1
 
ENGLISH5 QUARTER4 MODULE1 WEEK1-3 How Visual and Multimedia Elements.pptx
ENGLISH5 QUARTER4 MODULE1 WEEK1-3 How Visual and Multimedia Elements.pptxENGLISH5 QUARTER4 MODULE1 WEEK1-3 How Visual and Multimedia Elements.pptx
ENGLISH5 QUARTER4 MODULE1 WEEK1-3 How Visual and Multimedia Elements.pptxAnaBeatriceAblay2
 
_Math 4-Q4 Week 5.pptx Steps in Collecting Data
_Math 4-Q4 Week 5.pptx Steps in Collecting Data_Math 4-Q4 Week 5.pptx Steps in Collecting Data
_Math 4-Q4 Week 5.pptx Steps in Collecting DataJhengPantaleon
 
Biting mechanism of poisonous snakes.pdf
Biting mechanism of poisonous snakes.pdfBiting mechanism of poisonous snakes.pdf
Biting mechanism of poisonous snakes.pdfadityarao40181
 
“Oh GOSH! Reflecting on Hackteria's Collaborative Practices in a Global Do-It...
“Oh GOSH! Reflecting on Hackteria's Collaborative Practices in a Global Do-It...“Oh GOSH! Reflecting on Hackteria's Collaborative Practices in a Global Do-It...
“Oh GOSH! Reflecting on Hackteria's Collaborative Practices in a Global Do-It...Marc Dusseiller Dusjagr
 
Enzyme, Pharmaceutical Aids, Miscellaneous Last Part of Chapter no 5th.pdf
Enzyme, Pharmaceutical Aids, Miscellaneous Last Part of Chapter no 5th.pdfEnzyme, Pharmaceutical Aids, Miscellaneous Last Part of Chapter no 5th.pdf
Enzyme, Pharmaceutical Aids, Miscellaneous Last Part of Chapter no 5th.pdfSumit Tiwari
 
The Most Excellent Way | 1 Corinthians 13
The Most Excellent Way | 1 Corinthians 13The Most Excellent Way | 1 Corinthians 13
The Most Excellent Way | 1 Corinthians 13Steve Thomason
 
How to Make a Pirate ship Primary Education.pptx
How to Make a Pirate ship Primary Education.pptxHow to Make a Pirate ship Primary Education.pptx
How to Make a Pirate ship Primary Education.pptxmanuelaromero2013
 
call girls in Kamla Market (DELHI) 🔝 >༒9953330565🔝 genuine Escort Service 🔝✔️✔️
call girls in Kamla Market (DELHI) 🔝 >༒9953330565🔝 genuine Escort Service 🔝✔️✔️call girls in Kamla Market (DELHI) 🔝 >༒9953330565🔝 genuine Escort Service 🔝✔️✔️
call girls in Kamla Market (DELHI) 🔝 >༒9953330565🔝 genuine Escort Service 🔝✔️✔️9953056974 Low Rate Call Girls In Saket, Delhi NCR
 
CARE OF CHILD IN INCUBATOR..........pptx
CARE OF CHILD IN INCUBATOR..........pptxCARE OF CHILD IN INCUBATOR..........pptx
CARE OF CHILD IN INCUBATOR..........pptxGaneshChakor2
 
Science lesson Moon for 4th quarter lesson
Science lesson Moon for 4th quarter lessonScience lesson Moon for 4th quarter lesson
Science lesson Moon for 4th quarter lessonJericReyAuditor
 
Solving Puzzles Benefits Everyone (English).pptx
Solving Puzzles Benefits Everyone (English).pptxSolving Puzzles Benefits Everyone (English).pptx
Solving Puzzles Benefits Everyone (English).pptxOH TEIK BIN
 
SOCIAL AND HISTORICAL CONTEXT - LFTVD.pptx
SOCIAL AND HISTORICAL CONTEXT - LFTVD.pptxSOCIAL AND HISTORICAL CONTEXT - LFTVD.pptx
SOCIAL AND HISTORICAL CONTEXT - LFTVD.pptxiammrhaywood
 
Crayon Activity Handout For the Crayon A
Crayon Activity Handout For the Crayon ACrayon Activity Handout For the Crayon A
Crayon Activity Handout For the Crayon AUnboundStockton
 
Painted Grey Ware.pptx, PGW Culture of India
Painted Grey Ware.pptx, PGW Culture of IndiaPainted Grey Ware.pptx, PGW Culture of India
Painted Grey Ware.pptx, PGW Culture of IndiaVirag Sontakke
 
Final demo Grade 9 for demo Plan dessert.pptx
Final demo Grade 9 for demo Plan dessert.pptxFinal demo Grade 9 for demo Plan dessert.pptx
Final demo Grade 9 for demo Plan dessert.pptxAvyJaneVismanos
 
Science 7 - LAND and SEA BREEZE and its Characteristics
Science 7 - LAND and SEA BREEZE and its CharacteristicsScience 7 - LAND and SEA BREEZE and its Characteristics
Science 7 - LAND and SEA BREEZE and its CharacteristicsKarinaGenton
 
ECONOMIC CONTEXT - LONG FORM TV DRAMA - PPT
ECONOMIC CONTEXT - LONG FORM TV DRAMA - PPTECONOMIC CONTEXT - LONG FORM TV DRAMA - PPT
ECONOMIC CONTEXT - LONG FORM TV DRAMA - PPTiammrhaywood
 

Recently uploaded (20)

Alper Gobel In Media Res Media Component
Alper Gobel In Media Res Media ComponentAlper Gobel In Media Res Media Component
Alper Gobel In Media Res Media Component
 
ENGLISH5 QUARTER4 MODULE1 WEEK1-3 How Visual and Multimedia Elements.pptx
ENGLISH5 QUARTER4 MODULE1 WEEK1-3 How Visual and Multimedia Elements.pptxENGLISH5 QUARTER4 MODULE1 WEEK1-3 How Visual and Multimedia Elements.pptx
ENGLISH5 QUARTER4 MODULE1 WEEK1-3 How Visual and Multimedia Elements.pptx
 
_Math 4-Q4 Week 5.pptx Steps in Collecting Data
_Math 4-Q4 Week 5.pptx Steps in Collecting Data_Math 4-Q4 Week 5.pptx Steps in Collecting Data
_Math 4-Q4 Week 5.pptx Steps in Collecting Data
 
Biting mechanism of poisonous snakes.pdf
Biting mechanism of poisonous snakes.pdfBiting mechanism of poisonous snakes.pdf
Biting mechanism of poisonous snakes.pdf
 
“Oh GOSH! Reflecting on Hackteria's Collaborative Practices in a Global Do-It...
“Oh GOSH! Reflecting on Hackteria's Collaborative Practices in a Global Do-It...“Oh GOSH! Reflecting on Hackteria's Collaborative Practices in a Global Do-It...
“Oh GOSH! Reflecting on Hackteria's Collaborative Practices in a Global Do-It...
 
Enzyme, Pharmaceutical Aids, Miscellaneous Last Part of Chapter no 5th.pdf
Enzyme, Pharmaceutical Aids, Miscellaneous Last Part of Chapter no 5th.pdfEnzyme, Pharmaceutical Aids, Miscellaneous Last Part of Chapter no 5th.pdf
Enzyme, Pharmaceutical Aids, Miscellaneous Last Part of Chapter no 5th.pdf
 
The Most Excellent Way | 1 Corinthians 13
The Most Excellent Way | 1 Corinthians 13The Most Excellent Way | 1 Corinthians 13
The Most Excellent Way | 1 Corinthians 13
 
Staff of Color (SOC) Retention Efforts DDSD
Staff of Color (SOC) Retention Efforts DDSDStaff of Color (SOC) Retention Efforts DDSD
Staff of Color (SOC) Retention Efforts DDSD
 
How to Make a Pirate ship Primary Education.pptx
How to Make a Pirate ship Primary Education.pptxHow to Make a Pirate ship Primary Education.pptx
How to Make a Pirate ship Primary Education.pptx
 
call girls in Kamla Market (DELHI) 🔝 >༒9953330565🔝 genuine Escort Service 🔝✔️✔️
call girls in Kamla Market (DELHI) 🔝 >༒9953330565🔝 genuine Escort Service 🔝✔️✔️call girls in Kamla Market (DELHI) 🔝 >༒9953330565🔝 genuine Escort Service 🔝✔️✔️
call girls in Kamla Market (DELHI) 🔝 >༒9953330565🔝 genuine Escort Service 🔝✔️✔️
 
CARE OF CHILD IN INCUBATOR..........pptx
CARE OF CHILD IN INCUBATOR..........pptxCARE OF CHILD IN INCUBATOR..........pptx
CARE OF CHILD IN INCUBATOR..........pptx
 
Science lesson Moon for 4th quarter lesson
Science lesson Moon for 4th quarter lessonScience lesson Moon for 4th quarter lesson
Science lesson Moon for 4th quarter lesson
 
Solving Puzzles Benefits Everyone (English).pptx
Solving Puzzles Benefits Everyone (English).pptxSolving Puzzles Benefits Everyone (English).pptx
Solving Puzzles Benefits Everyone (English).pptx
 
SOCIAL AND HISTORICAL CONTEXT - LFTVD.pptx
SOCIAL AND HISTORICAL CONTEXT - LFTVD.pptxSOCIAL AND HISTORICAL CONTEXT - LFTVD.pptx
SOCIAL AND HISTORICAL CONTEXT - LFTVD.pptx
 
Crayon Activity Handout For the Crayon A
Crayon Activity Handout For the Crayon ACrayon Activity Handout For the Crayon A
Crayon Activity Handout For the Crayon A
 
Model Call Girl in Bikash Puri Delhi reach out to us at 🔝9953056974🔝
Model Call Girl in Bikash Puri  Delhi reach out to us at 🔝9953056974🔝Model Call Girl in Bikash Puri  Delhi reach out to us at 🔝9953056974🔝
Model Call Girl in Bikash Puri Delhi reach out to us at 🔝9953056974🔝
 
Painted Grey Ware.pptx, PGW Culture of India
Painted Grey Ware.pptx, PGW Culture of IndiaPainted Grey Ware.pptx, PGW Culture of India
Painted Grey Ware.pptx, PGW Culture of India
 
Final demo Grade 9 for demo Plan dessert.pptx
Final demo Grade 9 for demo Plan dessert.pptxFinal demo Grade 9 for demo Plan dessert.pptx
Final demo Grade 9 for demo Plan dessert.pptx
 
Science 7 - LAND and SEA BREEZE and its Characteristics
Science 7 - LAND and SEA BREEZE and its CharacteristicsScience 7 - LAND and SEA BREEZE and its Characteristics
Science 7 - LAND and SEA BREEZE and its Characteristics
 
ECONOMIC CONTEXT - LONG FORM TV DRAMA - PPT
ECONOMIC CONTEXT - LONG FORM TV DRAMA - PPTECONOMIC CONTEXT - LONG FORM TV DRAMA - PPT
ECONOMIC CONTEXT - LONG FORM TV DRAMA - PPT
 

BAS 150 Lesson 4 Lecture

  • 1. BAS 150 Lesson 4: Creating and Managing SAS Datasets & Formats and Labels
  • 2. • Create a permanent SAS data set • Effectively manage multiple SAS data sets and libraries • Modify SAS data sets • Evaluate the difference in data formats and labels • Create a new variable in SAS using formats This Lesson’s Learning Objectives
  • 3. SAS Data Sets  SAS datasets can be permanent or temporary.  Previously, we’ve used the data statement to create temporary SAS datasets.  In this lesson, we’ll learn how to create permanent SAS datasets using the data statement.
  • 4.  They are subdirectories or folders  They store SAS datasets  Starts with libname statement Understanding SAS Libraries (1 of 3)
  • 5.  Libref is the location name you give for the subdirectory where SAS needs to look for the dataset  You will refer to this libref further in your programs  The libref for this libname statement is: Understanding SAS Libraries (2 of 3)
  • 6.  Libref o Naming Rules  8 characters or less  Begin with character or underscore  No special characters or spaces o If you do not specify a libref…  Temporary save to work library Understanding SAS Libraries (3 of 3)
  • 7. Creating a Permanent SAS Dataset
  • 8.  Two parts o Descriptor o Data  PROC Statements o PROC Print o PROC Contents Format of SAS Datasets
  • 9. PROC Contents (1 of 2) PROC Contents can be used to display the metadata, or descriptor portion, of the SAS dataset.
  • 10. PROC Contents (2 of 2) Note the key parts: • Data set name • File name • Number of variables • Number of observations • Variable list Proc contents is an easy way to know what’s in your dataset
  • 11. PROC Contents: VARNUM Option  By default, all variables in the PROC contents procedure are listed alphabetically  Sometimes, it is useful to look at the variable list in the order they were created  This can be done using the VARNUM option. Before: After:
  • 12.  Useful for showing your results of your code  However, doing a default proc print option with a large dataset will generate endless pages of output and can even make SAS freeze.  It’s better to specify options when using PROC Print, which we’ll discuss next. PROC Print
  • 13.  There are several options for Proc Print: o Var – specifies the variables you want to print o Noobs – suppresses the default observation column o Obs – limits the number of observations PROC Print Options
  • 14. Importing a SAS Data Set  Soccer is the Library  Soccer_Scores is the dataset within the library.  No need for infile statements to retrieve data.  The set statement is like an input statement, but instead of reading in a raw data file, it reads observations from a SAS dataset.
  • 15. Modifying a SAS Data Set There are many different ways to modify a SAS data set. The example on the left uses the “Where” statement to subset the work.goals data set AND creates a new SAS data set called work.topgoals. Work.topgoals only includes observations where the goal variable is greater than or equal to 10 goals.
  • 17.  Label Statement  Apply in DATA or PROC step o DATA or PROC Datasets: permanent o PROC steps: temporary Using Labels (1 of 3)
  • 18. Using Labels (2 of 3) • The first label statement is in the data statement. • It creates permanent descriptors for the variables player, goals, age and years_playing • The second label statement is in the proc print statement. • Proc Print requires a label option when you want to display labels (instead of field names) in the column header, because the default is the variable name.
  • 19. Using Labels (3 of 3) • To the right is the output using our label statement • The headings are now the labels, instead of variable names.
  • 20.  Similar to labels  Define appearance of data  Grouping  Predefined or custom  Both Data and Proc steps o Data: Permanent o Proc: Temporary Formats
  • 21. Format Rules $ Indicates a character format. format Names the SAS format. w Specifies the total format width, including decimal places and special characters. . Is required syntax. Formats always contain a period (.) as part of the name. d Specifies the number of decimal places to display in numeric formats. <$>format<w>.<d>
  • 22. Commonly Used SAS Formats Format Definition $w. Writes standard character data. w.d Writes standard numeric data. COMMAw.d Writes numeric values with a comma that separates every three digits and a period that separates the decimal fraction. DOLLARw.d Writes numeric values with a leading dollar sign, a comma that separates every three digits, and a period that separates the decimal fraction. COMMAXw.d Writes numeric values with a period that separates every three digits and a comma that separates the decimal fraction. EUROXw.d Writes numeric values with a leading euro symbol (€), a period that separates every three digits, and a comma that separates the decimal fraction.
  • 23. Pre-formatted value Format Formatted value 2125854 comma10. 2,125,854 52115 dollar14.2 $52,115.00 17526 mmddyy8. 12/26/07 17526 weekdate. Wednesday, December 26, 2007 M $Gender. Male 12 AgeGroup. Under 18 C $PassFail. Passing Grade Examples of Formats
  • 25. Specifying Ranges of Values Age of Player Value 5 - 6 Level 1 7-9 Level 2 10-12 Level 3 We can create our own formats to simplify data presentation by creating groups. From the Soccer data, we can create a format for age so that each value represents a “Playing Level” Example: Soccer players that are 5 or 6 years old are considered a “Level 1”, where those that are 7,8 or 9 are considered “Level 2”
  • 26. Defining a Numeric Format Using PROC Format We create a new format called “level”. This format will convert the age variable into playing levels 1 – 3. Notice we do not reference age at all in the proc statement. Why? Because a format can be used for any variable.
  • 27. Applying a Numeric Format Once we’ve created the format, we can use it in PROC PRINT Notice the period at the end of the second group of statements. This is important and an easy place to make an error! Remember, there is no period when you create the format, but a period is required when you use it.
  • 28. Viewing the Output Note: I changed the age variable label to ‘Playing Level’ for reporting purposes
  • 29. Creating a New Variable in SAS Instead of changing the variable label name for age, we can create a new variable called “Playing_Level”. By using a PUT statement we can combine the age variable and the format level to create “Playing_Level”. The Output.
  • 30. • Create a permanent SAS data set • Effectively manage multiple SAS data sets and libraries • Modify SAS data sets • Evaluate the difference in data formats and labels • Create a new variable in SAS using formats Summary - Learning Objectives
  • 31. “This workforce solution was funded by a grant awarded by the U.S. Department of Labor’s Employment and Training Administration. The solution was created by the grantee and does not necessarily reflect the official position of the U.S. Department of Labor. The Department of Labor makes no guarantees, warranties, or assurances of any kind, express or implied, with respect to such information, including any information on linked sites and including, but not limited to, accuracy of the information or its completeness, timeliness, usefulness, adequacy, continued availability, or ownership.” Except where otherwise stated, this work by Wake Technical Community College Building Capacity in Business Analytics, a Department of Labor, TAACCCT funded project, is licensed under the Creative Commons Attribution 4.0 International License. To view a copy of this license, visit http://creativecommons.org/licenses/by/4.0/ Copyright Information