beginning data manipulation hrp 223 - topic 4 oct 19 th 2011

Post on 19-Dec-2015

214 Views

Category:

Documents

0 Downloads

Preview:

Click to see full reader

TRANSCRIPT

Beginning Data Manipulation

HRP 223 - Topic 4Oct 19th 2011

Some fake dataPr

oced

ures

Functions

Procedures summarize over a dataset

Functions work on a within a record of a

dataset.

Notice SAS remembers the capitalization

Print a Dataset

What SAS writes

Labels fix these

Formats fix these

Formats fix these

I changed the capitalization.

Aver

age

mon

ths

trea

tmen

t

Calculate a mean

Average 3 labs

Search the function list in onlineDoc for a function that does average.

Modifying datasets with SQL

I like to split my .egp file into several process flowcharts.

• One sets the libraries and formats.• One does cleaning.• One (or several) for analyses.

Right click here and choose Properties.

Label this process flow Make data.

Note the name.

Note the new name.

Automatically Make Libraries and/or Formats

• You can make a process flow that runs whenever you start up your project. Just name the process flow autoexec.

User Defined Formats

• I typically create my formats with code but if you want to use the GUI.

Set this

A short name

After pushing Run fix the node name to match the format.

Make At Least 1 Analysis Process Flow

• If you have an autoexec file you don’t need to include the library in the analysis sheet but I like to see it:

Moving Between Process Flows

Here

Or here

Need a new variable?

• You can check a value using an if statement in a data step:

else

• If the value is not greater than or equal to 175 then set the result to be good:

New character variables are 8 letters wide if you use an input statement. Otherwise it uses the first reference

to set the length.

It gets the length for existing variables from

the first reference in the source dataset.

Change this to "Bad " or use a length statement.

Missing values are negative

infinity….

You can get the same result with SQL.

Showing Combinations

• Often I am asked to show sets of treatments or sets of drugs. This quickly gets too complex for contingency tables (for 5 treatments you need 2x2x2x2x2 tables).

• I use binary lists. For example, common cancer treatments include Chemo, Radiation, Surgery (but you can use this same system for fine distinctions). Somebody who got Chemo and Surgery but no radiation can be represented as CrS. Code everybody like that and count the combinations.

top related