Presentation is loading. Please wait.

Presentation is loading. Please wait.

Lecture 4 Ways to get data into SAS Some practice programming

Similar presentations


Presentation on theme: "Lecture 4 Ways to get data into SAS Some practice programming"— Presentation transcript:

1 Lecture 4 Ways to get data into SAS Some practice programming
Review of statistical concepts

2 Getting data into SAS DATALINES statement INFILE statement PROC IMPORT
Data is contained within a data step INFILE statement Data contained in separate file PROC IMPORT

3 * List Directed Input: Reading data values separated by spaces.;
DATA bp; INFILE DATALINES; INPUT clinic $ dbp6 sbp6 dbpbl sbpbl; DATALINES; C D A A C ; RUN ; TITLE 'Data Separated by Spaces'; PROC PRINT DATA=bp; RUN; Obs clinic dbp6 sbp6 dbpbl sbpbl C D A A C

4 * List Directed Input: Reading data values separated by commas;
DATA bp; INFILE DATALINES DLM = ',' ; INPUT clinic $ dbp6 sbp6 dbpbl sbpbl; DATALINES; C,84,138,93,143 D,89,150,91,140 A,78,116,100,162 A,.,.,86,155 C,81,145,86,140 ; RUN ; TITLE 'Data separated by a comma'; PROC PRINT DATA=bp; RUN;

5 * List Directed Input: Reading data values from a .csv type file;
DATA bp; INFILE DATALINES DLM = ',' DSD ; INPUT clinic $ dbp6 sbp6 dbpbl sbpbl; DATALINES; C,84,138,93,143 D,89,150,91,140 A,78,116,100,162 A,,,86,155 C,81,145,86,140 ; TITLE 'Reading in Data using the DSD Option'; PROC PRINT DATA=bp; RUN;

6 List Directed Input: Reading data values separated by tabs (
* List Directed Input: Reading data values separated by tabs (.txt files); DATA bp; INFILE DATALINES DLM = '09'x DSD; INPUT clinic $ dbp6 sbp6 dbpbl sbpbl; DATALINES; C D A A C ; TITLE 'Reading in Data separated by a tab'; PROC PRINT DATA=bp; RUN;

7 * Reading data from an external file
DATA bp; INFILE '/home/ph5415/data/bp.csv' DSD FIRSTOBS = 2; INPUT clinic $ dbp6 sbp6 dbpbl sbpbl ; TITLE 'Reading in Data from an External File'; PROC PRINT DATA=bp; clinic,dbp6,sbp6,dbpbl,sbpbl C,84,138,93,143 D,89,150,91,140 A,78,116,100,162 A,,,86,155 C,81,145,86,140 Content of bp.csv

8 *Using PROC IMPORT to read in data ;
PROC IMPORT DATAFILE='/home/ph5415/data/bp.csv' OUT = bp DBMS = csv REPLACE ; GETNAMES = yes; TITLE 'Reading in Data Using PROC IMPORT'; PROC PRINT DATA=bp; PROC CONTENTS DATA=bp;

9 The CONTENTS Procedure
Data Set Name: WORK.BP Observations: Member Type: DATA Variables: Engine: V Indexes: Created: :15 Tuesday, January 25, Observation Length: 40 Last Modified: 18:15 Tuesday, January 25, Deleted Observations: 0 Protection: Compressed: NO Data Set Type: Sorted: NO Label: -----Alphabetic List of Variables and Attributes----- # Variable Type Len Pos ƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒ 1 clinic Char 2 dbp Num 4 dbpbl Num 3 sbp Num 5 sbpbl Num

10 Some Definitions Statistics: The art and science of collecting, analyzing, presenting, and interpreting numerical data. Data: facts and figures that are analyzed Dataset: All the data collected for a study Elements: Units in which data is collected People, companies, schools, households Variables: Characteristics measured on elements People (height, weight) Company (number of employees) Schools (percentage of students who graduate in 5 years) Households (number of computers owned)

11 Informal Definition Statistics:
In a scientific way gain information about something you do not know

12 Start With Research Question
What is the proportion of persons without health insurance in Minnesota? Do newer BP medications prevent heart disease compared to older medications? What is the relationship between grade point average and SAT scores Do persons who eat more F&V have lower risk of developing colon cancer. Does the program DARE reduce the risk of young persons trying drugs?

13 Statistics Design Study And Question Collect Data Make Conclusions
Start With Question Design Study And Collect Data Make Conclusions (Inference) Compute Summary Data to Assess Question.

14 Statistical Inference
Estimation (Chapter 4) Hypothesis Testing (Chapter 5) Comparing population proportions (Chap 6) Comparing population means (Chap 7)

15 Common Parameters to Estimate
Parameter Description m Mean of population p Proportion with a certain trait r Correlation between 2 variables m1 - m2 Difference between 2 means p1 - p2 Difference between 2 proportions s Population standard deviation

16 Statistical Inference
Population with mean m = ? A simple random sample of n elements is selected from the population. The value of is used to make inferences about the value of m. The sample data provide a value for the sample mean .

17 Sampling Sample: a subset of target population
(usually a simple random sample - each sample has equal probability of occurring) Different samples yield different estimates Trying to understand the population parameter (the “true value”) It’s usually not possible to measure the population value

18 Point Estimate Parameter Point Estimate m Sample mean p
Sample proportion r Sample correlation m1 - m2 Difference between 2 sample means p1 - p2 Difference between 2 sample proportions s Sample standard deviation

19 Interval Estimation In general, confidence intervals are of the form:
Estimate = mean, proportion, regression coefficient, odds ratio... SE = standard error of your estimate 1.96 = for 95% CI based on normal distribution

20 Estimates the population mean:
Estimation “What is the average total cholesterol level for MN residents?” Random sample of cholesterol levels sample mean = sum of values / number of observations Estimates the population mean:

21 estimates the population standard deviation:
Estimation “What is the average total cholesterol level for MN residents?” sample standard deviation: estimates the population standard deviation:

22 Confidence Interval Example
Suppose sample of 100 mean = 215 mg/dL, standard deviation = 20 95% CI = = standard error of mean = ( *20/10, *20/10) approximately = (211, 219)

23 Properties of Confidence Intervals
As sample size increases, CI gets smaller If you could sample the whole population; Can use different levels of confidence 90, 95, 99% common More confidence means larger interval; so a 90% CI is smaller than a 99% CI Changes with population standard deviation More variable population means larger interval

24 Caution with Confidence Intervals
Data should be from random sample More complicated sampling requires different methods Example - multistage or stratified sampling Outliers can cause problems Non-normal data can change confidence level Skewed data a big problem Bias not accounted for Non-responders Target and sampled population different

25 95% Confidence Intervals with SAS
1) Construct from output estimate +/- 1.96*SE 2) Provided automatically by some procedures PROC MEANS DATA = STUDENTS LCLM UCLM; VAR AGE;


Download ppt "Lecture 4 Ways to get data into SAS Some practice programming"

Similar presentations


Ads by Google