SlideShare a Scribd company logo
Edpsych/Psych/Stat 587
Hierarchical Linear Models
Fall 2012
C.J. Anderson
Introduction to SAS: General
There are 5 main working environments (windows) in SAS:
• Explorer window: Lets you view data in SAS data sets or go to output for
specific commands.
• Editor window: This is where you enter SAS commands (programs).
• Log window: Commands entered and run are repeated here along with warning
and error messages can be found in the log window. Also, when you create a data
set, information about the data set is printed (e.g., number of observations,
variables, etc).
• Output window: A plain text window with the results of your analyses.
• Results window: If you have the option set to produce HTML output, a “nice”
looking output can be found here.
When you open SAS you will see:
Some basic SAS syntax
• Just like sentences end with periods, “.”, all SAS commands must end with a
semicolon “;”
• It is good practice to put comments in your SAS programs. Comments begin with
an asterisk “*” and end with a semicolon “;”. For example.
*HSB: empty/Null HLM;
Or
/* your comment goes here */
• SAS variable names:
o 1 to 32 characters in length
o They must begin with a letter (A-Z). Note that SAS does is
not case sensitive; that is, it read “A” and “a” as the same.
o The second and remaining characters in a variable name
can be other letters, numbers, or underscores (i.e., “_”).
o By default SAS assumes that variables are numeric. If a
variable is character, then the name must be followed by a
space and then a $.
Two basic steps in a SAS program
(1) The DATA step: create or read in data, modify variables, create
new variables, etc.
(2) PROCEDCURE step (PROC for short): data analysis
SAS Example
1. Go to course web-site and download HSB1dat.sas and save it in the My Documents
directory and give it the name sasintro.sas
2. Click on SAS icon (or click on sasintro.sas ).
3. Find File on the main tool bar: File > Open program >
Use Browse to find the file sasintro.sas. Click on this file and push the OPEN button.
If all went well, a file should have opened in your “program” window and look
something like this….
/* HSB dat1 : level 1 responses (of students) */
data hsb1;
input id minority female ses mathach;
label id='school'
minority='Student ethnicity (1=minority, 0=not)'
female ='student gener (1=female, 0=male)'
ses='standardized scale of student ses'
mathach='Mathematics achievement';
datalines;
1224 .000 1.000 -1.528 5.876
1224 .000 1.000 -.588 19.708
1224 .000 .000 -.528 20.349
1224 .000 .000 -.668 8.781
1224 .000 .000 -.158 17.898
1224 .000 .000 .022 4.583
1224 .000 1.000 -.618 -2.832
1224 .000 .000 -.998 .523
.
.
.
run;
4. Click on the run icon (it looks like a little person running).
Check the log file to make sure everything ran OK. If everything went well you should
see:
NOTE: The data set WORK.HSB1 has 7185 observations and 5 variables.
NOTE: DATA statement used (Total process time):
real time 0.34 seconds
cpu time 0.03 seconds
5. Try some procedures:
a) Create a cross-classification of two (or more or less) variables:
PROC FREQ DATA= hsb1;
TABLES minority*female / NOROW NOCOL ;
RUN;
b) Compute the mean of SES and math achievement scores;
PROC MEANS DATA= hsb1;
VAR ses mathach;
RUN;
c) Sort the data by school id.
PROC SORT DATA= hsb1;
BY id;
RUN;
d) Compute the means of SES and math achievement for each school and save
the results to a file, which we then print to see what’s in the save (working file).
PROC MEANS DATA= hsb1;
CLASS id;
VAR ses mathach;
OUTPUT OUT=mymeans MEAN=mses mmath STD=stdses
stdmath;
PROC PRINT DATA=mymeans;
RUN;
5. Save your program commands to a file:
a) Make sure that your program window is the current/open window.
b) File > Save As > …..give it a descriptive name….
Save your program commands often!
8. Save your output to a file:
a) Make sure that your listing/output window is the current/open window.
b) File > Save As > …..give it a name with either type .lst or .txt
c) You can also save your output as an .rtf file and then use MSWord to edit
it.
Additional Tips:
• Always, always check the log file after you run some code.
• Write a few lines and then run to make sure that code is OK.
• If you get an error message in the log file, find the first errors. Correcting this
might take care of any subsequent errors.
• Common errors:
o Forgetting the semi-colon at the end of a statement.
o Not closing a quoted string (e.g., for TITLE or LABEL).
o Spelling error.
Introduction to sas
Introduction to sas

More Related Content

Viewers also liked

Htn pharmacotherapy
Htn pharmacotherapyHtn pharmacotherapy
Htn pharmacotherapy
Dr P Deepak
 
Ald
AldAld
Corticosteriods
CorticosteriodsCorticosteriods
Corticosteriods
Dr P Deepak
 
6122 htn lp_01.12.06
6122 htn lp_01.12.066122 htn lp_01.12.06
6122 htn lp_01.12.06
Dr P Deepak
 
Ichdii cranial
Ichdii cranialIchdii cranial
Ichdii cranial
Dr P Deepak
 
En atbantibiotics
En atbantibioticsEn atbantibiotics
En atbantibiotics
Dr P Deepak
 
Cardiology pharmacology
Cardiology pharmacologyCardiology pharmacology
Cardiology pharmacology
gshave
 
Audit
AuditAudit
2010 cv pharm slp
2010 cv pharm slp2010 cv pharm slp
2010 cv pharm slp
Dr P Deepak
 
Malabsorption
MalabsorptionMalabsorption
Malabsorption
Dr P Deepak
 
Antihistamines and-asthma-patients-2002
Antihistamines and-asthma-patients-2002Antihistamines and-asthma-patients-2002
Antihistamines and-asthma-patients-2002
Dr P Deepak
 
Asia new frontier_white_paper
Asia new frontier_white_paperAsia new frontier_white_paper
Asia new frontier_white_paper
Dr P Deepak
 
Malaria treatment protocol
Malaria treatment protocolMalaria treatment protocol
Malaria treatment protocol
Dr P Deepak
 
Ctg underlying pathophysiology
Ctg underlying pathophysiologyCtg underlying pathophysiology
Ctg underlying pathophysiology
Dr P Deepak
 
Sas code for examples from a first course in statistics
Sas code for examples from a first course in statisticsSas code for examples from a first course in statistics
Sas code for examples from a first course in statistics
Dr P Deepak
 
Differentiating trigeminal neuropathy from trigeminal neuralgia
Differentiating trigeminal neuropathy from trigeminal neuralgiaDifferentiating trigeminal neuropathy from trigeminal neuralgia
Differentiating trigeminal neuropathy from trigeminal neuralgia
Dr P Deepak
 
Review anti-cancer agents in medicinal chemistry, 2013
Review anti-cancer agents in medicinal chemistry, 2013Review anti-cancer agents in medicinal chemistry, 2013
Review anti-cancer agents in medicinal chemistry, 2013
Dr P Deepak
 
Ad hoc reporting
Ad hoc reportingAd hoc reporting
Ad hoc reporting
Dr P Deepak
 
Clinical pharm ro
Clinical pharm roClinical pharm ro
Clinical pharm ro
Dr P Deepak
 
Beck depression-inventory-real-time-report
Beck depression-inventory-real-time-reportBeck depression-inventory-real-time-report
Beck depression-inventory-real-time-report
Dr P Deepak
 

Viewers also liked (20)

Htn pharmacotherapy
Htn pharmacotherapyHtn pharmacotherapy
Htn pharmacotherapy
 
Ald
AldAld
Ald
 
Corticosteriods
CorticosteriodsCorticosteriods
Corticosteriods
 
6122 htn lp_01.12.06
6122 htn lp_01.12.066122 htn lp_01.12.06
6122 htn lp_01.12.06
 
Ichdii cranial
Ichdii cranialIchdii cranial
Ichdii cranial
 
En atbantibiotics
En atbantibioticsEn atbantibiotics
En atbantibiotics
 
Cardiology pharmacology
Cardiology pharmacologyCardiology pharmacology
Cardiology pharmacology
 
Audit
AuditAudit
Audit
 
2010 cv pharm slp
2010 cv pharm slp2010 cv pharm slp
2010 cv pharm slp
 
Malabsorption
MalabsorptionMalabsorption
Malabsorption
 
Antihistamines and-asthma-patients-2002
Antihistamines and-asthma-patients-2002Antihistamines and-asthma-patients-2002
Antihistamines and-asthma-patients-2002
 
Asia new frontier_white_paper
Asia new frontier_white_paperAsia new frontier_white_paper
Asia new frontier_white_paper
 
Malaria treatment protocol
Malaria treatment protocolMalaria treatment protocol
Malaria treatment protocol
 
Ctg underlying pathophysiology
Ctg underlying pathophysiologyCtg underlying pathophysiology
Ctg underlying pathophysiology
 
Sas code for examples from a first course in statistics
Sas code for examples from a first course in statisticsSas code for examples from a first course in statistics
Sas code for examples from a first course in statistics
 
Differentiating trigeminal neuropathy from trigeminal neuralgia
Differentiating trigeminal neuropathy from trigeminal neuralgiaDifferentiating trigeminal neuropathy from trigeminal neuralgia
Differentiating trigeminal neuropathy from trigeminal neuralgia
 
Review anti-cancer agents in medicinal chemistry, 2013
Review anti-cancer agents in medicinal chemistry, 2013Review anti-cancer agents in medicinal chemistry, 2013
Review anti-cancer agents in medicinal chemistry, 2013
 
Ad hoc reporting
Ad hoc reportingAd hoc reporting
Ad hoc reporting
 
Clinical pharm ro
Clinical pharm roClinical pharm ro
Clinical pharm ro
 
Beck depression-inventory-real-time-report
Beck depression-inventory-real-time-reportBeck depression-inventory-real-time-report
Beck depression-inventory-real-time-report
 

Similar to Introduction to sas

8323 Stats - Lesson 1 - 03 Introduction To Sas 2008
8323 Stats - Lesson 1 - 03 Introduction To Sas 20088323 Stats - Lesson 1 - 03 Introduction To Sas 2008
8323 Stats - Lesson 1 - 03 Introduction To Sas 2008
untellectualism
 
Introduction to SAS
Introduction to SASIntroduction to SAS
Introduction to SAS
Imam Jaffer
 
INTRODUCTION TO SAS
INTRODUCTION TO SASINTRODUCTION TO SAS
INTRODUCTION TO SAS
Bhuwanesh Rawat
 
Base sas 2 sas windowing environment
Base sas 2  sas windowing environmentBase sas 2  sas windowing environment
Base sas 2 sas windowing environment
singhvikram549
 
Spss basics tutorial
Spss basics tutorialSpss basics tutorial
Spss basics tutorial
santoshranjan77
 
Sas - Introduction to working under change management
Sas - Introduction to working under change managementSas - Introduction to working under change management
Sas - Introduction to working under change management
Vibrant Technologies & Computers
 
Introduction To Sas
Introduction To SasIntroduction To Sas
Introduction To Sas
halasti
 
Introduction to-sas-1211594349119006-8
Introduction to-sas-1211594349119006-8Introduction to-sas-1211594349119006-8
Introduction to-sas-1211594349119006-8
thotakoti
 
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...
Oracle Apps R12, Financials,SCM,PA,HRMSCorporate Training
 
SAS Programming Notes
SAS Programming NotesSAS Programming Notes
SAS Programming Notes
Gnana Murthy A
 
pm1
pm1pm1
5116427.ppt
5116427.ppt5116427.ppt
5116427.ppt
BAGARAGAZAROMUALD2
 
SPSS: Quick Look
SPSS: Quick LookSPSS: Quick Look
SPSS: Quick Look
DataminingTools Inc
 
Chapter -1.pptx0p0p0pppopooopopppp0ppoooooo
Chapter -1.pptx0p0p0pppopooopopppp0ppooooooChapter -1.pptx0p0p0pppopooopopppp0ppoooooo
Chapter -1.pptx0p0p0pppopooopopppp0ppoooooo
bizuayehuadmasu1
 
Managing ASQ Data: a Guide for Relief Nursery Administrative Assistants
Managing ASQ Data: a Guide for Relief Nursery Administrative AssistantsManaging ASQ Data: a Guide for Relief Nursery Administrative Assistants
Managing ASQ Data: a Guide for Relief Nursery Administrative Assistants
Tinasky
 
Chapter -1.pptx
Chapter -1.pptxChapter -1.pptx
Chapter -1.pptx
bizuayehuadmasu1
 
SAS BASICS
SAS BASICSSAS BASICS
SAS BASICS
Bhuwanesh Rawat
 
Hechsp 001 Chapter 2
Hechsp 001 Chapter 2Hechsp 001 Chapter 2
Hechsp 001 Chapter 2
Brian Kelly
 
Spss tutorial 1
Spss tutorial 1Spss tutorial 1
Spss tutorial 1
debataraja
 
Spss tutorial 1
Spss tutorial 1Spss tutorial 1
Spss tutorial 1
kunkumabala
 

Similar to Introduction to sas (20)

8323 Stats - Lesson 1 - 03 Introduction To Sas 2008
8323 Stats - Lesson 1 - 03 Introduction To Sas 20088323 Stats - Lesson 1 - 03 Introduction To Sas 2008
8323 Stats - Lesson 1 - 03 Introduction To Sas 2008
 
Introduction to SAS
Introduction to SASIntroduction to SAS
Introduction to SAS
 
INTRODUCTION TO SAS
INTRODUCTION TO SASINTRODUCTION TO SAS
INTRODUCTION TO SAS
 
Base sas 2 sas windowing environment
Base sas 2  sas windowing environmentBase sas 2  sas windowing environment
Base sas 2 sas windowing environment
 
Spss basics tutorial
Spss basics tutorialSpss basics tutorial
Spss basics tutorial
 
Sas - Introduction to working under change management
Sas - Introduction to working under change managementSas - Introduction to working under change management
Sas - Introduction to working under change management
 
Introduction To Sas
Introduction To SasIntroduction To Sas
Introduction To Sas
 
Introduction to-sas-1211594349119006-8
Introduction to-sas-1211594349119006-8Introduction to-sas-1211594349119006-8
Introduction to-sas-1211594349119006-8
 
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...
 
SAS Programming Notes
SAS Programming NotesSAS Programming Notes
SAS Programming Notes
 
pm1
pm1pm1
pm1
 
5116427.ppt
5116427.ppt5116427.ppt
5116427.ppt
 
SPSS: Quick Look
SPSS: Quick LookSPSS: Quick Look
SPSS: Quick Look
 
Chapter -1.pptx0p0p0pppopooopopppp0ppoooooo
Chapter -1.pptx0p0p0pppopooopopppp0ppooooooChapter -1.pptx0p0p0pppopooopopppp0ppoooooo
Chapter -1.pptx0p0p0pppopooopopppp0ppoooooo
 
Managing ASQ Data: a Guide for Relief Nursery Administrative Assistants
Managing ASQ Data: a Guide for Relief Nursery Administrative AssistantsManaging ASQ Data: a Guide for Relief Nursery Administrative Assistants
Managing ASQ Data: a Guide for Relief Nursery Administrative Assistants
 
Chapter -1.pptx
Chapter -1.pptxChapter -1.pptx
Chapter -1.pptx
 
SAS BASICS
SAS BASICSSAS BASICS
SAS BASICS
 
Hechsp 001 Chapter 2
Hechsp 001 Chapter 2Hechsp 001 Chapter 2
Hechsp 001 Chapter 2
 
Spss tutorial 1
Spss tutorial 1Spss tutorial 1
Spss tutorial 1
 
Spss tutorial 1
Spss tutorial 1Spss tutorial 1
Spss tutorial 1
 

More from Dr P Deepak

Mal3
Mal3Mal3
Occipitalneuralgia
OccipitalneuralgiaOccipitalneuralgia
Occipitalneuralgia
Dr P Deepak
 
Studying drug induced-disease
Studying drug induced-diseaseStudying drug induced-disease
Studying drug induced-disease
Dr P Deepak
 
Strom11206
Strom11206Strom11206
Strom11206
Dr P Deepak
 
Nln pharmacology study guide final 6 3-2013
Nln pharmacology study guide final 6 3-2013Nln pharmacology study guide final 6 3-2013
Nln pharmacology study guide final 6 3-2013
Dr P Deepak
 
Base sas interview questions
Base sas interview questionsBase sas interview questions
Base sas interview questions
Dr P Deepak
 
Case presentation on gastroenteritis and acute renal failure
Case presentation on gastroenteritis and acute renal failureCase presentation on gastroenteritis and acute renal failure
Case presentation on gastroenteritis and acute renal failure
Dr P Deepak
 

More from Dr P Deepak (7)

Mal3
Mal3Mal3
Mal3
 
Occipitalneuralgia
OccipitalneuralgiaOccipitalneuralgia
Occipitalneuralgia
 
Studying drug induced-disease
Studying drug induced-diseaseStudying drug induced-disease
Studying drug induced-disease
 
Strom11206
Strom11206Strom11206
Strom11206
 
Nln pharmacology study guide final 6 3-2013
Nln pharmacology study guide final 6 3-2013Nln pharmacology study guide final 6 3-2013
Nln pharmacology study guide final 6 3-2013
 
Base sas interview questions
Base sas interview questionsBase sas interview questions
Base sas interview questions
 
Case presentation on gastroenteritis and acute renal failure
Case presentation on gastroenteritis and acute renal failureCase presentation on gastroenteritis and acute renal failure
Case presentation on gastroenteritis and acute renal failure
 

Recently uploaded

Skybuffer SAM4U tool for SAP license adoption
Skybuffer SAM4U tool for SAP license adoptionSkybuffer SAM4U tool for SAP license adoption
Skybuffer SAM4U tool for SAP license adoption
Tatiana Kojar
 
Digital Marketing Trends in 2024 | Guide for Staying Ahead
Digital Marketing Trends in 2024 | Guide for Staying AheadDigital Marketing Trends in 2024 | Guide for Staying Ahead
Digital Marketing Trends in 2024 | Guide for Staying Ahead
Wask
 
HCL Notes and Domino License Cost Reduction in the World of DLAU
HCL Notes and Domino License Cost Reduction in the World of DLAUHCL Notes and Domino License Cost Reduction in the World of DLAU
HCL Notes and Domino License Cost Reduction in the World of DLAU
panagenda
 
Recommendation System using RAG Architecture
Recommendation System using RAG ArchitectureRecommendation System using RAG Architecture
Recommendation System using RAG Architecture
fredae14
 
Building Production Ready Search Pipelines with Spark and Milvus
Building Production Ready Search Pipelines with Spark and MilvusBuilding Production Ready Search Pipelines with Spark and Milvus
Building Production Ready Search Pipelines with Spark and Milvus
Zilliz
 
Deep Dive: Getting Funded with Jason Jason Lemkin Founder & CEO @ SaaStr
Deep Dive: Getting Funded with Jason Jason Lemkin Founder & CEO @ SaaStrDeep Dive: Getting Funded with Jason Jason Lemkin Founder & CEO @ SaaStr
Deep Dive: Getting Funded with Jason Jason Lemkin Founder & CEO @ SaaStr
saastr
 
Driving Business Innovation: Latest Generative AI Advancements & Success Story
Driving Business Innovation: Latest Generative AI Advancements & Success StoryDriving Business Innovation: Latest Generative AI Advancements & Success Story
Driving Business Innovation: Latest Generative AI Advancements & Success Story
Safe Software
 
TrustArc Webinar - 2024 Global Privacy Survey
TrustArc Webinar - 2024 Global Privacy SurveyTrustArc Webinar - 2024 Global Privacy Survey
TrustArc Webinar - 2024 Global Privacy Survey
TrustArc
 
System Design Case Study: Building a Scalable E-Commerce Platform - Hiike
System Design Case Study: Building a Scalable E-Commerce Platform - HiikeSystem Design Case Study: Building a Scalable E-Commerce Platform - Hiike
System Design Case Study: Building a Scalable E-Commerce Platform - Hiike
Hiike
 
Energy Efficient Video Encoding for Cloud and Edge Computing Instances
Energy Efficient Video Encoding for Cloud and Edge Computing InstancesEnergy Efficient Video Encoding for Cloud and Edge Computing Instances
Energy Efficient Video Encoding for Cloud and Edge Computing Instances
Alpen-Adria-Universität
 
Columbus Data & Analytics Wednesdays - June 2024
Columbus Data & Analytics Wednesdays - June 2024Columbus Data & Analytics Wednesdays - June 2024
Columbus Data & Analytics Wednesdays - June 2024
Jason Packer
 
Azure API Management to expose backend services securely
Azure API Management to expose backend services securelyAzure API Management to expose backend services securely
Azure API Management to expose backend services securely
Dinusha Kumarasiri
 
Unlock the Future of Search with MongoDB Atlas_ Vector Search Unleashed.pdf
Unlock the Future of Search with MongoDB Atlas_ Vector Search Unleashed.pdfUnlock the Future of Search with MongoDB Atlas_ Vector Search Unleashed.pdf
Unlock the Future of Search with MongoDB Atlas_ Vector Search Unleashed.pdf
Malak Abu Hammad
 
Let's Integrate MuleSoft RPA, COMPOSER, APM with AWS IDP along with Slack
Let's Integrate MuleSoft RPA, COMPOSER, APM with AWS IDP along with SlackLet's Integrate MuleSoft RPA, COMPOSER, APM with AWS IDP along with Slack
Let's Integrate MuleSoft RPA, COMPOSER, APM with AWS IDP along with Slack
shyamraj55
 
Fueling AI with Great Data with Airbyte Webinar
Fueling AI with Great Data with Airbyte WebinarFueling AI with Great Data with Airbyte Webinar
Fueling AI with Great Data with Airbyte Webinar
Zilliz
 
HCL Notes und Domino Lizenzkostenreduzierung in der Welt von DLAU
HCL Notes und Domino Lizenzkostenreduzierung in der Welt von DLAUHCL Notes und Domino Lizenzkostenreduzierung in der Welt von DLAU
HCL Notes und Domino Lizenzkostenreduzierung in der Welt von DLAU
panagenda
 
Programming Foundation Models with DSPy - Meetup Slides
Programming Foundation Models with DSPy - Meetup SlidesProgramming Foundation Models with DSPy - Meetup Slides
Programming Foundation Models with DSPy - Meetup Slides
Zilliz
 
Operating System Used by Users in day-to-day life.pptx
Operating System Used by Users in day-to-day life.pptxOperating System Used by Users in day-to-day life.pptx
Operating System Used by Users in day-to-day life.pptx
Pravash Chandra Das
 
5th LF Energy Power Grid Model Meet-up Slides
5th LF Energy Power Grid Model Meet-up Slides5th LF Energy Power Grid Model Meet-up Slides
5th LF Energy Power Grid Model Meet-up Slides
DanBrown980551
 
Letter and Document Automation for Bonterra Impact Management (fka Social Sol...
Letter and Document Automation for Bonterra Impact Management (fka Social Sol...Letter and Document Automation for Bonterra Impact Management (fka Social Sol...
Letter and Document Automation for Bonterra Impact Management (fka Social Sol...
Jeffrey Haguewood
 

Recently uploaded (20)

Skybuffer SAM4U tool for SAP license adoption
Skybuffer SAM4U tool for SAP license adoptionSkybuffer SAM4U tool for SAP license adoption
Skybuffer SAM4U tool for SAP license adoption
 
Digital Marketing Trends in 2024 | Guide for Staying Ahead
Digital Marketing Trends in 2024 | Guide for Staying AheadDigital Marketing Trends in 2024 | Guide for Staying Ahead
Digital Marketing Trends in 2024 | Guide for Staying Ahead
 
HCL Notes and Domino License Cost Reduction in the World of DLAU
HCL Notes and Domino License Cost Reduction in the World of DLAUHCL Notes and Domino License Cost Reduction in the World of DLAU
HCL Notes and Domino License Cost Reduction in the World of DLAU
 
Recommendation System using RAG Architecture
Recommendation System using RAG ArchitectureRecommendation System using RAG Architecture
Recommendation System using RAG Architecture
 
Building Production Ready Search Pipelines with Spark and Milvus
Building Production Ready Search Pipelines with Spark and MilvusBuilding Production Ready Search Pipelines with Spark and Milvus
Building Production Ready Search Pipelines with Spark and Milvus
 
Deep Dive: Getting Funded with Jason Jason Lemkin Founder & CEO @ SaaStr
Deep Dive: Getting Funded with Jason Jason Lemkin Founder & CEO @ SaaStrDeep Dive: Getting Funded with Jason Jason Lemkin Founder & CEO @ SaaStr
Deep Dive: Getting Funded with Jason Jason Lemkin Founder & CEO @ SaaStr
 
Driving Business Innovation: Latest Generative AI Advancements & Success Story
Driving Business Innovation: Latest Generative AI Advancements & Success StoryDriving Business Innovation: Latest Generative AI Advancements & Success Story
Driving Business Innovation: Latest Generative AI Advancements & Success Story
 
TrustArc Webinar - 2024 Global Privacy Survey
TrustArc Webinar - 2024 Global Privacy SurveyTrustArc Webinar - 2024 Global Privacy Survey
TrustArc Webinar - 2024 Global Privacy Survey
 
System Design Case Study: Building a Scalable E-Commerce Platform - Hiike
System Design Case Study: Building a Scalable E-Commerce Platform - HiikeSystem Design Case Study: Building a Scalable E-Commerce Platform - Hiike
System Design Case Study: Building a Scalable E-Commerce Platform - Hiike
 
Energy Efficient Video Encoding for Cloud and Edge Computing Instances
Energy Efficient Video Encoding for Cloud and Edge Computing InstancesEnergy Efficient Video Encoding for Cloud and Edge Computing Instances
Energy Efficient Video Encoding for Cloud and Edge Computing Instances
 
Columbus Data & Analytics Wednesdays - June 2024
Columbus Data & Analytics Wednesdays - June 2024Columbus Data & Analytics Wednesdays - June 2024
Columbus Data & Analytics Wednesdays - June 2024
 
Azure API Management to expose backend services securely
Azure API Management to expose backend services securelyAzure API Management to expose backend services securely
Azure API Management to expose backend services securely
 
Unlock the Future of Search with MongoDB Atlas_ Vector Search Unleashed.pdf
Unlock the Future of Search with MongoDB Atlas_ Vector Search Unleashed.pdfUnlock the Future of Search with MongoDB Atlas_ Vector Search Unleashed.pdf
Unlock the Future of Search with MongoDB Atlas_ Vector Search Unleashed.pdf
 
Let's Integrate MuleSoft RPA, COMPOSER, APM with AWS IDP along with Slack
Let's Integrate MuleSoft RPA, COMPOSER, APM with AWS IDP along with SlackLet's Integrate MuleSoft RPA, COMPOSER, APM with AWS IDP along with Slack
Let's Integrate MuleSoft RPA, COMPOSER, APM with AWS IDP along with Slack
 
Fueling AI with Great Data with Airbyte Webinar
Fueling AI with Great Data with Airbyte WebinarFueling AI with Great Data with Airbyte Webinar
Fueling AI with Great Data with Airbyte Webinar
 
HCL Notes und Domino Lizenzkostenreduzierung in der Welt von DLAU
HCL Notes und Domino Lizenzkostenreduzierung in der Welt von DLAUHCL Notes und Domino Lizenzkostenreduzierung in der Welt von DLAU
HCL Notes und Domino Lizenzkostenreduzierung in der Welt von DLAU
 
Programming Foundation Models with DSPy - Meetup Slides
Programming Foundation Models with DSPy - Meetup SlidesProgramming Foundation Models with DSPy - Meetup Slides
Programming Foundation Models with DSPy - Meetup Slides
 
Operating System Used by Users in day-to-day life.pptx
Operating System Used by Users in day-to-day life.pptxOperating System Used by Users in day-to-day life.pptx
Operating System Used by Users in day-to-day life.pptx
 
5th LF Energy Power Grid Model Meet-up Slides
5th LF Energy Power Grid Model Meet-up Slides5th LF Energy Power Grid Model Meet-up Slides
5th LF Energy Power Grid Model Meet-up Slides
 
Letter and Document Automation for Bonterra Impact Management (fka Social Sol...
Letter and Document Automation for Bonterra Impact Management (fka Social Sol...Letter and Document Automation for Bonterra Impact Management (fka Social Sol...
Letter and Document Automation for Bonterra Impact Management (fka Social Sol...
 

Introduction to sas

  • 1. Edpsych/Psych/Stat 587 Hierarchical Linear Models Fall 2012 C.J. Anderson Introduction to SAS: General There are 5 main working environments (windows) in SAS: • Explorer window: Lets you view data in SAS data sets or go to output for specific commands. • Editor window: This is where you enter SAS commands (programs). • Log window: Commands entered and run are repeated here along with warning and error messages can be found in the log window. Also, when you create a data set, information about the data set is printed (e.g., number of observations, variables, etc). • Output window: A plain text window with the results of your analyses. • Results window: If you have the option set to produce HTML output, a “nice” looking output can be found here. When you open SAS you will see:
  • 2.
  • 3. Some basic SAS syntax • Just like sentences end with periods, “.”, all SAS commands must end with a semicolon “;” • It is good practice to put comments in your SAS programs. Comments begin with an asterisk “*” and end with a semicolon “;”. For example. *HSB: empty/Null HLM; Or /* your comment goes here */ • SAS variable names: o 1 to 32 characters in length o They must begin with a letter (A-Z). Note that SAS does is not case sensitive; that is, it read “A” and “a” as the same. o The second and remaining characters in a variable name can be other letters, numbers, or underscores (i.e., “_”). o By default SAS assumes that variables are numeric. If a variable is character, then the name must be followed by a space and then a $. Two basic steps in a SAS program (1) The DATA step: create or read in data, modify variables, create new variables, etc. (2) PROCEDCURE step (PROC for short): data analysis SAS Example 1. Go to course web-site and download HSB1dat.sas and save it in the My Documents directory and give it the name sasintro.sas 2. Click on SAS icon (or click on sasintro.sas ). 3. Find File on the main tool bar: File > Open program > Use Browse to find the file sasintro.sas. Click on this file and push the OPEN button. If all went well, a file should have opened in your “program” window and look something like this….
  • 4. /* HSB dat1 : level 1 responses (of students) */ data hsb1; input id minority female ses mathach; label id='school' minority='Student ethnicity (1=minority, 0=not)' female ='student gener (1=female, 0=male)' ses='standardized scale of student ses' mathach='Mathematics achievement'; datalines; 1224 .000 1.000 -1.528 5.876 1224 .000 1.000 -.588 19.708 1224 .000 .000 -.528 20.349 1224 .000 .000 -.668 8.781 1224 .000 .000 -.158 17.898 1224 .000 .000 .022 4.583 1224 .000 1.000 -.618 -2.832 1224 .000 .000 -.998 .523 . . . run; 4. Click on the run icon (it looks like a little person running). Check the log file to make sure everything ran OK. If everything went well you should see: NOTE: The data set WORK.HSB1 has 7185 observations and 5 variables. NOTE: DATA statement used (Total process time): real time 0.34 seconds cpu time 0.03 seconds 5. Try some procedures: a) Create a cross-classification of two (or more or less) variables: PROC FREQ DATA= hsb1; TABLES minority*female / NOROW NOCOL ; RUN; b) Compute the mean of SES and math achievement scores; PROC MEANS DATA= hsb1; VAR ses mathach; RUN; c) Sort the data by school id. PROC SORT DATA= hsb1; BY id; RUN;
  • 5. d) Compute the means of SES and math achievement for each school and save the results to a file, which we then print to see what’s in the save (working file). PROC MEANS DATA= hsb1; CLASS id; VAR ses mathach; OUTPUT OUT=mymeans MEAN=mses mmath STD=stdses stdmath; PROC PRINT DATA=mymeans; RUN; 5. Save your program commands to a file: a) Make sure that your program window is the current/open window. b) File > Save As > …..give it a descriptive name…. Save your program commands often! 8. Save your output to a file: a) Make sure that your listing/output window is the current/open window. b) File > Save As > …..give it a name with either type .lst or .txt c) You can also save your output as an .rtf file and then use MSWord to edit it. Additional Tips: • Always, always check the log file after you run some code. • Write a few lines and then run to make sure that code is OK. • If you get an error message in the log file, find the first errors. Correcting this might take care of any subsequent errors. • Common errors: o Forgetting the semi-colon at the end of a statement. o Not closing a quoted string (e.g., for TITLE or LABEL). o Spelling error.