SlideShare a Scribd company logo
1 of 7
Download to read offline
SAS Tips and Tricks
Disclaimer: I am not an expert in SAS. These are just a few tricks I have picked up along the
way.
Saving Data Files
Note: You can skip this step entirely by reading the data in directly from a URL if you’d like.
Scroll down to ”Reading from a URL” to see how. For many classes, datasets are presented in
odd file types, such as .DAT. This can be problematic. The following steps ensure your data will
easily be read into SAS: (Note: the images I show work in Excel 2003. I am sure there are similar
processes in Excel 2007 and other versions.)
• Step One:
Save the dataset where you can find it. You can save it as any type you want. Open the
data with Excel.
• Step Two:
The data will probably be read into one column, with spaces and/or tabs between the
numbers. To fix this, click Data → Text to Columns.
• Step Three:
Indicate that the data is separated by Delimiters:
• Step Four:
Indicate that there may also be spaces used to separate values in the dataset:
D. Baumann, SAS Tips and Tricks 2008, 1 of 7
• Step Five:
Save the Excel file in any format you prefer. I suggest comma-delimited, or .csv.
To determine exactly where the file was saved (the full file extension), browse to the file. Once
there, right-click and select Properties:
The window that appears shows the Location of the saved file:
In the following tips and tricks, I simplify this to ’yourfileextension.’ Instead, substitute your full
file location and file name such as:
C:Documents and SettingsdbaumannDesktopCH01PR19.csv
Reading Data into SAS
D. Baumann, SAS Tips and Tricks 2008, 2 of 7
I have always found reading data into SAS to be the hardest part about using SAS. There are
essentially three ways to read data into SAS: importing the data, reading the data from a file,
and using cards/datalines.
1. Using ’proc import’
This is the point-and-click way to get files into SAS. Below are step-by-step instructions for
importing data. At the end, I have included the SAS code which performs the same steps.
This set of instructions assumes you have variable names in the first row of your datafile.
• Step One:
Click File → Import Data
• Step Two:
Choose which type of file you are importing. See the ’Data Cleaning’ section above for
tips. Click ’Next.’
D. Baumann, SAS Tips and Tricks 2008, 3 of 7
• Step Three:
Browse to the file you want to import (or type in the full extension – see ’Data Clean-
ing’ for tips). Click ”Next.’
• Step Four:
Indicate ’Library’ and ’Member.’ I leave the ’Library’ set to the default ’WORK,’ and
name ’Member’ whatever I want to name my dataset. Click ’Next.’
D. Baumann, SAS Tips and Tricks 2008, 4 of 7
• Step Five:
Create SAS Statements. I generally just skip this step. I will include the code which
SAS would output below. Click ’Finish.’
The data is now saved in SAS. To take a look at the data, type:
proc print data=yourdataname; run;
The SAS code that will perform these same steps automatically looks like:
proc import datafile=’yourfileextension’ out=test dbms=’Identifier’ replace; run;
Replace ’Identifier’ in the code above with one of the following:
Type Identifier
.csv CSV
.txt TAB
other DLM
2. Using the ’infile’ command
The second method for reading data into SAS is likely the most common. The difficulty
most people have with this method is dealing with various delimited files. Let’s assume you
named your data ’test’ and you have the full extension for your file (see above). (This can
be extended to more than just two variables as well.) The general framework is as follows:
data test;
infile ’yourfileextension’;
input variable1 variable2;
proc print data=test;
run;
The difficulty with most data sets is the delimiter, or the way the file indicates the end of
one number and the beginning of another. In most class datasets, this delimiter is a tab.
Other common delimiters are spaces and commas. In SAS, the ’data’ step, as above, sets
the default delimiter to be a space.
D. Baumann, SAS Tips and Tricks 2008, 5 of 7
To work with a tab delimited file, we need to specify the delimiter. This is done with the
dlm command right after your infile file extension:
infile ’yourfileextension’ dlm=’09’x;
Other common delimiters are as follows:
Delimiter Code
Tab dlm=’09’x
Comma dlm=’,’
Pipe dlm=’|’
3. Using ’cards’ or ’datalines’ This is probably the easiest method to use for small datasets.
Its usefulness decreases with large datasets because all of the data is written directly into
the SAS Editor.
I prefer to use cards, because I’ve found it can handle class datasets better. The typical
code is:
data test;
input variable1 variable2 variable3 $ ;
cards;
Insert your data here
;
proc print data=test;
run;
I have included the dollar sign ($) after variable3 which indicates a text variable. Notice
that there is a semicolon on the line after the data. When entered correctly, the data will
be highlighted in yellow. Most often, for classes, datasets will be formatted nicely, in clean
columns for each variable:
Variable 1 Variable 2 Variable 3
59 3.46 C
62 4.56 D
94 4.64 B
... ... ...
However, sometimes the data isn’t formatted so nicely:
59 3.46 C 62 4.56
D 94 4.64 B ...
To account for this, you can add ’@@’ to the end of your input line as follows:
input variable1 variable2 variable3 $ @@;
This takes groups of numbers together (based on how many variables you have), and con-
siders them to be a single observation. You only need to add ’@@,’ no matter how many
variables you have in your data.
D. Baumann, SAS Tips and Tricks 2008, 6 of 7
Reading from a URL
There is not a lot different between this method and the ’infile’ command above. However, this
can save the step of saving the data. The code looks like:
filename mydata url ’http://www.yourwebsite.com/datafile.txt’;
data a1;
infile mydata;
input Variable1 Variable2 Variable3;
proc print data=a1;
run;
The text right after ’filename’ in the first line defines the dataset name. ’url’ indicates that the
data is on a website which is defined in the ’http:// ... ’ step. Then, the ’infile’ command uses
that dataset as the source.
The same additional options that were found in the ’infile’ section still apply here.
D. Baumann, SAS Tips and Tricks 2008, 7 of 7

More Related Content

What's hot

What's hot (19)

Introduction to STATA - Ali Rashed
Introduction to STATA - Ali RashedIntroduction to STATA - Ali Rashed
Introduction to STATA - Ali Rashed
 
Mail merge in MS word MobView
Mail merge in MS word MobViewMail merge in MS word MobView
Mail merge in MS word MobView
 
Les25
Les25Les25
Les25
 
Micro project project co 3i
Micro project project co 3iMicro project project co 3i
Micro project project co 3i
 
Office excel tips and tricks 201101
Office excel tips and tricks 201101Office excel tips and tricks 201101
Office excel tips and tricks 201101
 
SAS Base Programmer Certification Training by Certified Experts
SAS Base Programmer Certification Training by Certified ExpertsSAS Base Programmer Certification Training by Certified Experts
SAS Base Programmer Certification Training by Certified Experts
 
SQL
SQL SQL
SQL
 
Mail merge
Mail mergeMail merge
Mail merge
 
5 saving data to the database
5 saving data to the database5 saving data to the database
5 saving data to the database
 
Web design - Working with Text and Lists in HTML
Web design - Working with Text and Lists in HTMLWeb design - Working with Text and Lists in HTML
Web design - Working with Text and Lists in HTML
 
Spss course session-II
Spss course session-IISpss course session-II
Spss course session-II
 
Data base
Data baseData base
Data base
 
SQL Basics
SQL BasicsSQL Basics
SQL Basics
 
MICRO PROJECT 22319 DMS
MICRO PROJECT 22319 DMSMICRO PROJECT 22319 DMS
MICRO PROJECT 22319 DMS
 
Intro To TSQL - Unit 5
Intro To TSQL - Unit 5Intro To TSQL - Unit 5
Intro To TSQL - Unit 5
 
Mail merge in_word_2010
Mail merge in_word_2010Mail merge in_word_2010
Mail merge in_word_2010
 
Database anomalies
Database anomaliesDatabase anomalies
Database anomalies
 
Mail Merge - Microsoft Office 2010
Mail Merge - Microsoft Office 2010Mail Merge - Microsoft Office 2010
Mail Merge - Microsoft Office 2010
 
Overview spss instructor
Overview spss instructorOverview spss instructor
Overview spss instructor
 

Viewers also liked

How financial planning aided a business hit by credit crunch
How financial planning aided a business hit by credit crunchHow financial planning aided a business hit by credit crunch
How financial planning aided a business hit by credit crunchFrank Nolan
 
Dallas Athletes Racing St. Patricks Day Triathlon Race Recon Clinic
Dallas Athletes Racing St. Patricks Day Triathlon Race Recon ClinicDallas Athletes Racing St. Patricks Day Triathlon Race Recon Clinic
Dallas Athletes Racing St. Patricks Day Triathlon Race Recon ClinicDavid Jimenez
 
いわゆるカスタムメイドのハイエンドのグッチベルトロット
いわゆるカスタムメイドのハイエンドのグッチベルトロットいわゆるカスタムメイドのハイエンドのグッチベルトロット
いわゆるカスタムメイドのハイエンドのグッチベルトロットboxian675
 
Informe Final Judecomuney 2016 al 17 08-2016
Informe Final Judecomuney 2016 al 17 08-2016Informe Final Judecomuney 2016 al 17 08-2016
Informe Final Judecomuney 2016 al 17 08-2016Jose Perez
 
Como utilizar los medios sociales para cumplir tus objetivos
Como utilizar los medios sociales para cumplir tus objetivosComo utilizar los medios sociales para cumplir tus objetivos
Como utilizar los medios sociales para cumplir tus objetivosMaría Rubio
 
Building a content community across government
Building a content community across governmentBuilding a content community across government
Building a content community across governmentPersis Howe
 
ICRISAT Vision and Values
ICRISAT Vision and Values ICRISAT Vision and Values
ICRISAT Vision and Values ICRISAT
 
Strategic Human Resource Management Lecture 2
Strategic Human Resource Management Lecture 2Strategic Human Resource Management Lecture 2
Strategic Human Resource Management Lecture 2RECONNECT
 
Strategic Human Resource Management Lecture 7
Strategic Human Resource Management Lecture 7Strategic Human Resource Management Lecture 7
Strategic Human Resource Management Lecture 7RECONNECT
 

Viewers also liked (11)

How financial planning aided a business hit by credit crunch
How financial planning aided a business hit by credit crunchHow financial planning aided a business hit by credit crunch
How financial planning aided a business hit by credit crunch
 
Programa2
Programa2 Programa2
Programa2
 
Dallas Athletes Racing St. Patricks Day Triathlon Race Recon Clinic
Dallas Athletes Racing St. Patricks Day Triathlon Race Recon ClinicDallas Athletes Racing St. Patricks Day Triathlon Race Recon Clinic
Dallas Athletes Racing St. Patricks Day Triathlon Race Recon Clinic
 
Padre nuestro
Padre nuestroPadre nuestro
Padre nuestro
 
いわゆるカスタムメイドのハイエンドのグッチベルトロット
いわゆるカスタムメイドのハイエンドのグッチベルトロットいわゆるカスタムメイドのハイエンドのグッチベルトロット
いわゆるカスタムメイドのハイエンドのグッチベルトロット
 
Informe Final Judecomuney 2016 al 17 08-2016
Informe Final Judecomuney 2016 al 17 08-2016Informe Final Judecomuney 2016 al 17 08-2016
Informe Final Judecomuney 2016 al 17 08-2016
 
Como utilizar los medios sociales para cumplir tus objetivos
Como utilizar los medios sociales para cumplir tus objetivosComo utilizar los medios sociales para cumplir tus objetivos
Como utilizar los medios sociales para cumplir tus objetivos
 
Building a content community across government
Building a content community across governmentBuilding a content community across government
Building a content community across government
 
ICRISAT Vision and Values
ICRISAT Vision and Values ICRISAT Vision and Values
ICRISAT Vision and Values
 
Strategic Human Resource Management Lecture 2
Strategic Human Resource Management Lecture 2Strategic Human Resource Management Lecture 2
Strategic Human Resource Management Lecture 2
 
Strategic Human Resource Management Lecture 7
Strategic Human Resource Management Lecture 7Strategic Human Resource Management Lecture 7
Strategic Human Resource Management Lecture 7
 

Similar to Essential SAS Tips

Unit I - introduction to r language 2.pptx
Unit I - introduction to r language 2.pptxUnit I - introduction to r language 2.pptx
Unit I - introduction to r language 2.pptxSreeLaya9
 
Basics Of SAS Programming Language
Basics Of SAS Programming LanguageBasics Of SAS Programming Language
Basics Of SAS Programming Languageguest2160992
 
Introduction to-sas-1211594349119006-8
Introduction to-sas-1211594349119006-8Introduction to-sas-1211594349119006-8
Introduction to-sas-1211594349119006-8thotakoti
 
Scanned by CamScannerModule 03 Lab WorksheetWeb Developmen.docx
Scanned by CamScannerModule 03 Lab WorksheetWeb Developmen.docxScanned by CamScannerModule 03 Lab WorksheetWeb Developmen.docx
Scanned by CamScannerModule 03 Lab WorksheetWeb Developmen.docxanhlodge
 
BRM_Data Analysis, Interpretation and Reporting Part I.ppt
BRM_Data Analysis, Interpretation and Reporting Part I.pptBRM_Data Analysis, Interpretation and Reporting Part I.ppt
BRM_Data Analysis, Interpretation and Reporting Part I.pptAbdifatahAhmedHurre
 
STATA_Training_for_data_science_juniors.pdf
STATA_Training_for_data_science_juniors.pdfSTATA_Training_for_data_science_juniors.pdf
STATA_Training_for_data_science_juniors.pdfAronMozart1
 
PATTERNS07 - Data Representation in C#
PATTERNS07 - Data Representation in C#PATTERNS07 - Data Representation in C#
PATTERNS07 - Data Representation in C#Michael Heron
 
Introduction To Sas
Introduction To SasIntroduction To Sas
Introduction To Sashalasti
 
An introduction to STATA.pdf
An introduction to STATA.pdfAn introduction to STATA.pdf
An introduction to STATA.pdfMd Nain
 
fINAL Lesson_5_Data_Manipulation_using_R_v1.pptx
fINAL Lesson_5_Data_Manipulation_using_R_v1.pptxfINAL Lesson_5_Data_Manipulation_using_R_v1.pptx
fINAL Lesson_5_Data_Manipulation_using_R_v1.pptxdataKarthik
 

Similar to Essential SAS Tips (20)

SAS Commands
SAS CommandsSAS Commands
SAS Commands
 
Stata tutorial university of princeton
Stata tutorial university of princetonStata tutorial university of princeton
Stata tutorial university of princeton
 
Unit I - introduction to r language 2.pptx
Unit I - introduction to r language 2.pptxUnit I - introduction to r language 2.pptx
Unit I - introduction to r language 2.pptx
 
Spss basics tutorial
Spss basics tutorialSpss basics tutorial
Spss basics tutorial
 
Basics Of SAS Programming Language
Basics Of SAS Programming LanguageBasics Of SAS Programming Language
Basics Of SAS Programming Language
 
Introduction to-sas-1211594349119006-8
Introduction to-sas-1211594349119006-8Introduction to-sas-1211594349119006-8
Introduction to-sas-1211594349119006-8
 
Scanned by CamScannerModule 03 Lab WorksheetWeb Developmen.docx
Scanned by CamScannerModule 03 Lab WorksheetWeb Developmen.docxScanned by CamScannerModule 03 Lab WorksheetWeb Developmen.docx
Scanned by CamScannerModule 03 Lab WorksheetWeb Developmen.docx
 
BRM_Data Analysis, Interpretation and Reporting Part I.ppt
BRM_Data Analysis, Interpretation and Reporting Part I.pptBRM_Data Analysis, Interpretation and Reporting Part I.ppt
BRM_Data Analysis, Interpretation and Reporting Part I.ppt
 
Databases By ZAK
Databases By ZAKDatabases By ZAK
Databases By ZAK
 
Sas training in hyderabad
Sas training in hyderabadSas training in hyderabad
Sas training in hyderabad
 
STATA_Training_for_data_science_juniors.pdf
STATA_Training_for_data_science_juniors.pdfSTATA_Training_for_data_science_juniors.pdf
STATA_Training_for_data_science_juniors.pdf
 
PATTERNS07 - Data Representation in C#
PATTERNS07 - Data Representation in C#PATTERNS07 - Data Representation in C#
PATTERNS07 - Data Representation in C#
 
Introduction To Sas
Introduction To SasIntroduction To Sas
Introduction To Sas
 
Sas classes in mumbai
Sas classes in mumbaiSas classes in mumbai
Sas classes in mumbai
 
DATA HANDLING FOR SPSS
DATA HANDLING FOR SPSSDATA HANDLING FOR SPSS
DATA HANDLING FOR SPSS
 
introduction-stata.pptx
introduction-stata.pptxintroduction-stata.pptx
introduction-stata.pptx
 
An introduction to STATA.pdf
An introduction to STATA.pdfAn introduction to STATA.pdf
An introduction to STATA.pdf
 
Cassandra data modelling best practices
Cassandra data modelling best practicesCassandra data modelling best practices
Cassandra data modelling best practices
 
pm1
pm1pm1
pm1
 
fINAL Lesson_5_Data_Manipulation_using_R_v1.pptx
fINAL Lesson_5_Data_Manipulation_using_R_v1.pptxfINAL Lesson_5_Data_Manipulation_using_R_v1.pptx
fINAL Lesson_5_Data_Manipulation_using_R_v1.pptx
 

Recently uploaded

Indian Call Girls in Abu Dhabi O5286O24O8 Call Girls in Abu Dhabi By Independ...
Indian Call Girls in Abu Dhabi O5286O24O8 Call Girls in Abu Dhabi By Independ...Indian Call Girls in Abu Dhabi O5286O24O8 Call Girls in Abu Dhabi By Independ...
Indian Call Girls in Abu Dhabi O5286O24O8 Call Girls in Abu Dhabi By Independ...dajasot375
 
Industrialised data - the key to AI success.pdf
Industrialised data - the key to AI success.pdfIndustrialised data - the key to AI success.pdf
Industrialised data - the key to AI success.pdfLars Albertsson
 
9654467111 Call Girls In Munirka Hotel And Home Service
9654467111 Call Girls In Munirka Hotel And Home Service9654467111 Call Girls In Munirka Hotel And Home Service
9654467111 Call Girls In Munirka Hotel And Home ServiceSapana Sha
 
How we prevented account sharing with MFA
How we prevented account sharing with MFAHow we prevented account sharing with MFA
How we prevented account sharing with MFAAndrei Kaleshka
 
High Class Call Girls Noida Sector 39 Aarushi 🔝8264348440🔝 Independent Escort...
High Class Call Girls Noida Sector 39 Aarushi 🔝8264348440🔝 Independent Escort...High Class Call Girls Noida Sector 39 Aarushi 🔝8264348440🔝 Independent Escort...
High Class Call Girls Noida Sector 39 Aarushi 🔝8264348440🔝 Independent Escort...soniya singh
 
1:1定制(UQ毕业证)昆士兰大学毕业证成绩单修改留信学历认证原版一模一样
1:1定制(UQ毕业证)昆士兰大学毕业证成绩单修改留信学历认证原版一模一样1:1定制(UQ毕业证)昆士兰大学毕业证成绩单修改留信学历认证原版一模一样
1:1定制(UQ毕业证)昆士兰大学毕业证成绩单修改留信学历认证原版一模一样vhwb25kk
 
B2 Creative Industry Response Evaluation.docx
B2 Creative Industry Response Evaluation.docxB2 Creative Industry Response Evaluation.docx
B2 Creative Industry Response Evaluation.docxStephen266013
 
PKS-TGC-1084-630 - Stage 1 Proposal.pptx
PKS-TGC-1084-630 - Stage 1 Proposal.pptxPKS-TGC-1084-630 - Stage 1 Proposal.pptx
PKS-TGC-1084-630 - Stage 1 Proposal.pptxPramod Kumar Srivastava
 
Data Science Jobs and Salaries Analysis.pptx
Data Science Jobs and Salaries Analysis.pptxData Science Jobs and Salaries Analysis.pptx
Data Science Jobs and Salaries Analysis.pptxFurkanTasci3
 
Brighton SEO | April 2024 | Data Storytelling
Brighton SEO | April 2024 | Data StorytellingBrighton SEO | April 2024 | Data Storytelling
Brighton SEO | April 2024 | Data StorytellingNeil Barnes
 
ASML's Taxonomy Adventure by Daniel Canter
ASML's Taxonomy Adventure by Daniel CanterASML's Taxonomy Adventure by Daniel Canter
ASML's Taxonomy Adventure by Daniel Cantervoginip
 
RadioAdProWritingCinderellabyButleri.pdf
RadioAdProWritingCinderellabyButleri.pdfRadioAdProWritingCinderellabyButleri.pdf
RadioAdProWritingCinderellabyButleri.pdfgstagge
 
VIP High Class Call Girls Jamshedpur Anushka 8250192130 Independent Escort Se...
VIP High Class Call Girls Jamshedpur Anushka 8250192130 Independent Escort Se...VIP High Class Call Girls Jamshedpur Anushka 8250192130 Independent Escort Se...
VIP High Class Call Girls Jamshedpur Anushka 8250192130 Independent Escort Se...Suhani Kapoor
 
Building on a FAIRly Strong Foundation to Connect Academic Research to Transl...
Building on a FAIRly Strong Foundation to Connect Academic Research to Transl...Building on a FAIRly Strong Foundation to Connect Academic Research to Transl...
Building on a FAIRly Strong Foundation to Connect Academic Research to Transl...Jack DiGiovanna
 
From idea to production in a day – Leveraging Azure ML and Streamlit to build...
From idea to production in a day – Leveraging Azure ML and Streamlit to build...From idea to production in a day – Leveraging Azure ML and Streamlit to build...
From idea to production in a day – Leveraging Azure ML and Streamlit to build...Florian Roscheck
 
꧁❤ Greater Noida Call Girls Delhi ❤꧂ 9711199171 ☎️ Hard And Sexy Vip Call
꧁❤ Greater Noida Call Girls Delhi ❤꧂ 9711199171 ☎️ Hard And Sexy Vip Call꧁❤ Greater Noida Call Girls Delhi ❤꧂ 9711199171 ☎️ Hard And Sexy Vip Call
꧁❤ Greater Noida Call Girls Delhi ❤꧂ 9711199171 ☎️ Hard And Sexy Vip Callshivangimorya083
 
Beautiful Sapna Vip Call Girls Hauz Khas 9711199012 Call /Whatsapps
Beautiful Sapna Vip  Call Girls Hauz Khas 9711199012 Call /WhatsappsBeautiful Sapna Vip  Call Girls Hauz Khas 9711199012 Call /Whatsapps
Beautiful Sapna Vip Call Girls Hauz Khas 9711199012 Call /Whatsappssapnasaifi408
 
RS 9000 Call In girls Dwarka Mor (DELHI)⇛9711147426🔝Delhi
RS 9000 Call In girls Dwarka Mor (DELHI)⇛9711147426🔝DelhiRS 9000 Call In girls Dwarka Mor (DELHI)⇛9711147426🔝Delhi
RS 9000 Call In girls Dwarka Mor (DELHI)⇛9711147426🔝Delhijennyeacort
 

Recently uploaded (20)

Indian Call Girls in Abu Dhabi O5286O24O8 Call Girls in Abu Dhabi By Independ...
Indian Call Girls in Abu Dhabi O5286O24O8 Call Girls in Abu Dhabi By Independ...Indian Call Girls in Abu Dhabi O5286O24O8 Call Girls in Abu Dhabi By Independ...
Indian Call Girls in Abu Dhabi O5286O24O8 Call Girls in Abu Dhabi By Independ...
 
Industrialised data - the key to AI success.pdf
Industrialised data - the key to AI success.pdfIndustrialised data - the key to AI success.pdf
Industrialised data - the key to AI success.pdf
 
Call Girls in Saket 99530🔝 56974 Escort Service
Call Girls in Saket 99530🔝 56974 Escort ServiceCall Girls in Saket 99530🔝 56974 Escort Service
Call Girls in Saket 99530🔝 56974 Escort Service
 
9654467111 Call Girls In Munirka Hotel And Home Service
9654467111 Call Girls In Munirka Hotel And Home Service9654467111 Call Girls In Munirka Hotel And Home Service
9654467111 Call Girls In Munirka Hotel And Home Service
 
How we prevented account sharing with MFA
How we prevented account sharing with MFAHow we prevented account sharing with MFA
How we prevented account sharing with MFA
 
High Class Call Girls Noida Sector 39 Aarushi 🔝8264348440🔝 Independent Escort...
High Class Call Girls Noida Sector 39 Aarushi 🔝8264348440🔝 Independent Escort...High Class Call Girls Noida Sector 39 Aarushi 🔝8264348440🔝 Independent Escort...
High Class Call Girls Noida Sector 39 Aarushi 🔝8264348440🔝 Independent Escort...
 
1:1定制(UQ毕业证)昆士兰大学毕业证成绩单修改留信学历认证原版一模一样
1:1定制(UQ毕业证)昆士兰大学毕业证成绩单修改留信学历认证原版一模一样1:1定制(UQ毕业证)昆士兰大学毕业证成绩单修改留信学历认证原版一模一样
1:1定制(UQ毕业证)昆士兰大学毕业证成绩单修改留信学历认证原版一模一样
 
B2 Creative Industry Response Evaluation.docx
B2 Creative Industry Response Evaluation.docxB2 Creative Industry Response Evaluation.docx
B2 Creative Industry Response Evaluation.docx
 
PKS-TGC-1084-630 - Stage 1 Proposal.pptx
PKS-TGC-1084-630 - Stage 1 Proposal.pptxPKS-TGC-1084-630 - Stage 1 Proposal.pptx
PKS-TGC-1084-630 - Stage 1 Proposal.pptx
 
Data Science Jobs and Salaries Analysis.pptx
Data Science Jobs and Salaries Analysis.pptxData Science Jobs and Salaries Analysis.pptx
Data Science Jobs and Salaries Analysis.pptx
 
Brighton SEO | April 2024 | Data Storytelling
Brighton SEO | April 2024 | Data StorytellingBrighton SEO | April 2024 | Data Storytelling
Brighton SEO | April 2024 | Data Storytelling
 
ASML's Taxonomy Adventure by Daniel Canter
ASML's Taxonomy Adventure by Daniel CanterASML's Taxonomy Adventure by Daniel Canter
ASML's Taxonomy Adventure by Daniel Canter
 
RadioAdProWritingCinderellabyButleri.pdf
RadioAdProWritingCinderellabyButleri.pdfRadioAdProWritingCinderellabyButleri.pdf
RadioAdProWritingCinderellabyButleri.pdf
 
VIP High Class Call Girls Jamshedpur Anushka 8250192130 Independent Escort Se...
VIP High Class Call Girls Jamshedpur Anushka 8250192130 Independent Escort Se...VIP High Class Call Girls Jamshedpur Anushka 8250192130 Independent Escort Se...
VIP High Class Call Girls Jamshedpur Anushka 8250192130 Independent Escort Se...
 
Building on a FAIRly Strong Foundation to Connect Academic Research to Transl...
Building on a FAIRly Strong Foundation to Connect Academic Research to Transl...Building on a FAIRly Strong Foundation to Connect Academic Research to Transl...
Building on a FAIRly Strong Foundation to Connect Academic Research to Transl...
 
From idea to production in a day – Leveraging Azure ML and Streamlit to build...
From idea to production in a day – Leveraging Azure ML and Streamlit to build...From idea to production in a day – Leveraging Azure ML and Streamlit to build...
From idea to production in a day – Leveraging Azure ML and Streamlit to build...
 
꧁❤ Greater Noida Call Girls Delhi ❤꧂ 9711199171 ☎️ Hard And Sexy Vip Call
꧁❤ Greater Noida Call Girls Delhi ❤꧂ 9711199171 ☎️ Hard And Sexy Vip Call꧁❤ Greater Noida Call Girls Delhi ❤꧂ 9711199171 ☎️ Hard And Sexy Vip Call
꧁❤ Greater Noida Call Girls Delhi ❤꧂ 9711199171 ☎️ Hard And Sexy Vip Call
 
Deep Generative Learning for All - The Gen AI Hype (Spring 2024)
Deep Generative Learning for All - The Gen AI Hype (Spring 2024)Deep Generative Learning for All - The Gen AI Hype (Spring 2024)
Deep Generative Learning for All - The Gen AI Hype (Spring 2024)
 
Beautiful Sapna Vip Call Girls Hauz Khas 9711199012 Call /Whatsapps
Beautiful Sapna Vip  Call Girls Hauz Khas 9711199012 Call /WhatsappsBeautiful Sapna Vip  Call Girls Hauz Khas 9711199012 Call /Whatsapps
Beautiful Sapna Vip Call Girls Hauz Khas 9711199012 Call /Whatsapps
 
RS 9000 Call In girls Dwarka Mor (DELHI)⇛9711147426🔝Delhi
RS 9000 Call In girls Dwarka Mor (DELHI)⇛9711147426🔝DelhiRS 9000 Call In girls Dwarka Mor (DELHI)⇛9711147426🔝Delhi
RS 9000 Call In girls Dwarka Mor (DELHI)⇛9711147426🔝Delhi
 

Essential SAS Tips

  • 1. SAS Tips and Tricks Disclaimer: I am not an expert in SAS. These are just a few tricks I have picked up along the way. Saving Data Files Note: You can skip this step entirely by reading the data in directly from a URL if you’d like. Scroll down to ”Reading from a URL” to see how. For many classes, datasets are presented in odd file types, such as .DAT. This can be problematic. The following steps ensure your data will easily be read into SAS: (Note: the images I show work in Excel 2003. I am sure there are similar processes in Excel 2007 and other versions.) • Step One: Save the dataset where you can find it. You can save it as any type you want. Open the data with Excel. • Step Two: The data will probably be read into one column, with spaces and/or tabs between the numbers. To fix this, click Data → Text to Columns. • Step Three: Indicate that the data is separated by Delimiters: • Step Four: Indicate that there may also be spaces used to separate values in the dataset: D. Baumann, SAS Tips and Tricks 2008, 1 of 7
  • 2. • Step Five: Save the Excel file in any format you prefer. I suggest comma-delimited, or .csv. To determine exactly where the file was saved (the full file extension), browse to the file. Once there, right-click and select Properties: The window that appears shows the Location of the saved file: In the following tips and tricks, I simplify this to ’yourfileextension.’ Instead, substitute your full file location and file name such as: C:Documents and SettingsdbaumannDesktopCH01PR19.csv Reading Data into SAS D. Baumann, SAS Tips and Tricks 2008, 2 of 7
  • 3. I have always found reading data into SAS to be the hardest part about using SAS. There are essentially three ways to read data into SAS: importing the data, reading the data from a file, and using cards/datalines. 1. Using ’proc import’ This is the point-and-click way to get files into SAS. Below are step-by-step instructions for importing data. At the end, I have included the SAS code which performs the same steps. This set of instructions assumes you have variable names in the first row of your datafile. • Step One: Click File → Import Data • Step Two: Choose which type of file you are importing. See the ’Data Cleaning’ section above for tips. Click ’Next.’ D. Baumann, SAS Tips and Tricks 2008, 3 of 7
  • 4. • Step Three: Browse to the file you want to import (or type in the full extension – see ’Data Clean- ing’ for tips). Click ”Next.’ • Step Four: Indicate ’Library’ and ’Member.’ I leave the ’Library’ set to the default ’WORK,’ and name ’Member’ whatever I want to name my dataset. Click ’Next.’ D. Baumann, SAS Tips and Tricks 2008, 4 of 7
  • 5. • Step Five: Create SAS Statements. I generally just skip this step. I will include the code which SAS would output below. Click ’Finish.’ The data is now saved in SAS. To take a look at the data, type: proc print data=yourdataname; run; The SAS code that will perform these same steps automatically looks like: proc import datafile=’yourfileextension’ out=test dbms=’Identifier’ replace; run; Replace ’Identifier’ in the code above with one of the following: Type Identifier .csv CSV .txt TAB other DLM 2. Using the ’infile’ command The second method for reading data into SAS is likely the most common. The difficulty most people have with this method is dealing with various delimited files. Let’s assume you named your data ’test’ and you have the full extension for your file (see above). (This can be extended to more than just two variables as well.) The general framework is as follows: data test; infile ’yourfileextension’; input variable1 variable2; proc print data=test; run; The difficulty with most data sets is the delimiter, or the way the file indicates the end of one number and the beginning of another. In most class datasets, this delimiter is a tab. Other common delimiters are spaces and commas. In SAS, the ’data’ step, as above, sets the default delimiter to be a space. D. Baumann, SAS Tips and Tricks 2008, 5 of 7
  • 6. To work with a tab delimited file, we need to specify the delimiter. This is done with the dlm command right after your infile file extension: infile ’yourfileextension’ dlm=’09’x; Other common delimiters are as follows: Delimiter Code Tab dlm=’09’x Comma dlm=’,’ Pipe dlm=’|’ 3. Using ’cards’ or ’datalines’ This is probably the easiest method to use for small datasets. Its usefulness decreases with large datasets because all of the data is written directly into the SAS Editor. I prefer to use cards, because I’ve found it can handle class datasets better. The typical code is: data test; input variable1 variable2 variable3 $ ; cards; Insert your data here ; proc print data=test; run; I have included the dollar sign ($) after variable3 which indicates a text variable. Notice that there is a semicolon on the line after the data. When entered correctly, the data will be highlighted in yellow. Most often, for classes, datasets will be formatted nicely, in clean columns for each variable: Variable 1 Variable 2 Variable 3 59 3.46 C 62 4.56 D 94 4.64 B ... ... ... However, sometimes the data isn’t formatted so nicely: 59 3.46 C 62 4.56 D 94 4.64 B ... To account for this, you can add ’@@’ to the end of your input line as follows: input variable1 variable2 variable3 $ @@; This takes groups of numbers together (based on how many variables you have), and con- siders them to be a single observation. You only need to add ’@@,’ no matter how many variables you have in your data. D. Baumann, SAS Tips and Tricks 2008, 6 of 7
  • 7. Reading from a URL There is not a lot different between this method and the ’infile’ command above. However, this can save the step of saving the data. The code looks like: filename mydata url ’http://www.yourwebsite.com/datafile.txt’; data a1; infile mydata; input Variable1 Variable2 Variable3; proc print data=a1; run; The text right after ’filename’ in the first line defines the dataset name. ’url’ indicates that the data is on a website which is defined in the ’http:// ... ’ step. Then, the ’infile’ command uses that dataset as the source. The same additional options that were found in the ’infile’ section still apply here. D. Baumann, SAS Tips and Tricks 2008, 7 of 7