DOC PREVIEW
MSU FW 893 - Lecture 8

This preview shows page 1-2 out of 7 pages.

Save
View full document
View full document
Premium Document
Do you want full access? Go Premium and unlock all 7 pages.
Access to all documents
Download any document
Ad free experience
View full document
Premium Document
Do you want full access? Go Premium and unlock all 7 pages.
Access to all documents
Download any document
Ad free experience
Premium Document
Do you want full access? Go Premium and unlock all 7 pages.
Access to all documents
Download any document
Ad free experience

Unformatted text preview:

Bringing Data into SASSlide 2Slide 3Slide 4Slide 5Slide 6In-class exercise/homeworkBringing Data into SAS•From Menu: –File–Import Data–Spreadsheet example first•Pick file by browsing•Select Library and Member (we will talk about this on the next slide•Create file that does import•Nothing happens! Meaning, you don’t see any results, but file is created–Look at import file that is created–Caution – need to worry about formats that are carried along during import. They may not be obvious!Bringing Data into SAS•Important Concepts in SAS–Permanent and Temporary datasets (tables)–LibrariesLibname class “c:\data\class\fw893”;data species;infile "c:\data\class\fw893\fish_species.txt";input species_code common $ 12-32 family $ genus $ species $;run;data class.species;infile "c:\data\class\fw893\fish_species.txt";input species_code common $ 12-32 family $ genus $ species $;run;{{This creates a temporary table named speciesThis creates a permanent table named speciesin the directoryspecified in the libname•ASCII files–May seem a bit harder than an Excel file, but more general–First need to examine structure of file so can import properly. I frequently use Notepad or similar simple text editor–Count columns, names of fields, etc.Bringing Data into SAS•Fish Species Table example:–Species Code column 1-2–Common name column 12-32–Family column 62-75–Genus column 112-125–Species column 162-174•Show SAS codeBringing Data into SAS•Important “Quirks”–Numeric fields can be imported without specifying column placement –Variables that are alphanumeric are followed by a dollar sign–If alphanumeric data do not have a space between them, AND text is 8 characters or less, you can import without specifying column placement. –Need to be careful if try to read beyond end of line by having too many fields (need to watch for ending fields that are empty)Bringing Data into SAS•Once you have a permanent dataset (table) created, you can read it in using the following syntax:Bringing Data into SASLibname class “c:\data\class\fw893”;data class.species;infile "c:\data\class\fw893\fish_species.txt";input species_code common $ 12-32 family $ genus $ species $;run;data dummy;set class.species;run;You can think of the “DATA” step as meaning “create the following table”You can think of the “SET” command as meaning “use the following table”In-class exercise/homework•Import the data in sample_list.txt and print out the table in SAS•Import the data in sample_list.xls files into SAS and print out the resulting table. How do they compare•Try to read in the transect data set (which is a permanent data set) from the class drive, and print off this dataset. Note you will need to specify the correct library


View Full Document

MSU FW 893 - Lecture 8

Documents in this Course
Load more
Download Lecture 8
Our administrator received your request to download this document. We will send you the file to your email shortly.
Loading Unlocking...
Login

Join to view Lecture 8 and access 3M+ class-specific study document.

or
We will never post anything without your permission.
Don't have an account?
Sign Up

Join to view Lecture 8 2 2 and access 3M+ class-specific study document.

or

By creating an account you agree to our Privacy Policy and Terms Of Use

Already a member?