Land birds around Morro Bay

This is a useful website for identifying land birds around Morro Bay.

This is a really comprehensive birding site

So far, I’ve identified:
Chestnut-backed Chickadee

Posted in Land birds, Wildlife | Leave a comment

Learning SAS – Accessing Data – Part 02

Data maybe structured or unstructured and in different formats and locations (Excel, SAS, etc).

Structured data has defined rows and columns that SAS knows how to read. For example, SAS, Microsoft Access, Excel, Oracle, Teradata, Hadoop, etc. SAS has engines that enable SAS to read structured data.

Unstructured data doesn’t have defined columns. Tab-delimited data may appear to be in columns, but it’s not really. For example, text, delimited, JSON, weblogs, etc. Data must be imported into SAS.


SAS Table

Structured data with defined rows and columns.
Extension of .sas7bdat
Two portions of table: Descriptor (metadata or properties) – table name, number of rows, data/time created, column names, column attributes. The data portion – data values stored in columns.
In SAS, a table is also called a data set. A column can also be called a variable. A row can also be called an observation.

Column attributes – in order to be defined
Name – 1 to 32 chars long; start with letter or underscore; continues with letters, numbers or underscores. Uppercase, lowercase, or mixed case. Ideally, stick to one naming convention.
Type – Character (letters; numbers; special characters, blanks) and Numeric (digits 0 to 9; minus sign; decimal point; scientific notation). SAS Dates are of numeric and start with 01Jan1960 (positive) and negative before that date.
Length – number of bytes allocated to store column values. Numeric is default to 8 bytes (16 sig digits). Characters are 1 to 32,767 bytes with one byte being one character.

Listing table and column attributes
Can use Proc contents data against the data set to examine values.
PROC CONTENTS DATA=data-set;
RUN;

Accessing Data thru Libraries
-It’s all about location and filetype. By using libraries, you can resolve many issues that would otherwise be hard-coding within code.
-Creating a library: LIBNAME libref engine “path”;
libref – is the library name
engine – name of behind scenes engine for reading structured data – Base; Excel; Teradata; Hadoop, etc
path – location (physical path)
Note: Location is relative to where SAS is running
Note: After setting up the library:
proc contents data=mylib.class;
run;

-Various libraries:
Work – temporary for session
SASHELP – same tables and other files

options validvarname=v7; – conforms standards within SAS of Excel formatting
libname xlstorm xlsx “s:/filepathname/storm.xlsx”;– xlstorm library and xlsx engine and path
proc contents data=xlstorm.storm_summary;
run;

libname xlstorm clear; — clears library

Importing Data into SAS (including unstructured)
-Unstructured needs to be structured first before going into SAS program
-You enter the type of data file
-You can accept default of SAS guessing first 20 rows to resolve column name and lengths, or tell it to review all records.
-If the source XCL file changes, you just re-run the proc import step

Posted in Programming, SAS | Leave a comment

Learning SAS (University; LinkedIn; 9.4; Certification) – Part 01

Over the years, I’ve wanted to learn SAS. While at USC, I heard about SAS University, which originally required downloading software onto something like a Virtual Machine (I used VirtualBox). Recently, everything has shifted to online, which makes life easier.

LinkedIn Learning (formerly Lynda.com) has a bunch of intro to SAS Programming courses towards a Basic Programming certification (SAS 9.4 Certification)

I’ll be creating blog posts for each of the lessons. The basic steps I’ll be following are: Access Data; Explore Data; Prepare Data; Analyze and Report on Data; Export results.

My immediate thought is that SAS will be useful for analyzing data that I’m researching regarding women in aviation. There are a series of datasets from the FAA.

SAS Programming Interfaces

SAS Studio
-This is a web-based interface between end-user and SAS
-Basics needed for programming (editor; messages – log; review output, reports, etc)

Browsing data within SAS Studio
-Libraries (on left pane)
-My Libraries (click on the twistie)
-SASHelp (various Sample SAS tables)
-CLASS Table – This opens, on the right, a bunch of columns and rows of students (age, height, etc)
Note: It’s easy to select/deselect columns, and also move the column selector to the left for more space.
-To recreate “Program 1” – 7 blips icon (New Options), New SAS Program (F4)

-Initial sample code – reads sashelp.class and enters into myclass
data myclass;
TAB set sashelp.class;
run;

proc print data=myclass; — prints the myclass table
run;

After running, I have my table (columns, fields). I also have ability to look at: code; log; results; output data. Code is the program I just entered. Log gives a summary of what happened, including total CPU time used, etc and “Errors, Warnings and Notes”. Results is the table that was outputted. Output Data is what I originally had when I opened the sashelp.class table.

Size grid columns to content. This is a way of minimizing the field width, so you see more data on the screen. In Output data, either right click and select that, or you can set in preferences.

To run specific parts of the code:
-Select the lines you want

Have “Results” off to the side:
Drag Results to the right until the little icon turns green. It’s also obvious when it shades a block on the right. You can reverse by dragging results back to the where you started from.

SAS Syntax
-SAS Program is a sequence of steps
-DATA step or PROC (Procedure) steps
-The step will begin with either data or proc
-The steps will typically end with a “run;” statement
-In general, a data step reads data from input source; processes it; and creates a SAS table
-A data step may also filter, compute new columns, join tables, etc
-A proc step can generate reports, graphs, compute stat and analysis.
-All statements must end with a ;
-Some statements only have key words within the step, but may have something that are assignment statements
-Global Statements — outside of data and proc steps. Typically define option or settings for SAS session. Global statements do not need a run; statement after them

-Comments: For multiple lines of a comment — begin with /* and end with */
-Comments: To comment out a single line, lead with a “*”
-Comments: One way of creating a comment is: write the comment; select it; press “Command, /”

-Formatting the code: Ideally you have a blank line between steps. Also, use tabs to indent stuff. If you haven’t done this, there is a handy button called “Format code” that will do it for you. In the editor, the comment is in a green color

-Syntax Errors – finding and resolving: These are just a fact of life in programming. Misspelled keywords, unmatched quotation marks, invalid options, missing semicolons. SAS enters warning or error in log.
-Suggestion: Always look at the Log after running, and review from top to bottom. Look for obvious errors, including just before the highlighted line.

Posted in Programming, SAS | Leave a comment