ERROR: ERROR: ERROR:

Similar documents
ECLT 5810 SAS Programming - Introduction

Chapter 7 File Access. Chapter Table of Contents

A Simple Guide to Using SPSS (Statistical Package for the. Introduction. Steps for Analyzing Data. Social Sciences) for Windows

CS242 COMPUTER PROGRAMMING

Checking whether the protocol was followed: gender and age 51

Google Sheets: Spreadsheet basics

Paper # Jazz it up a Little with Formats. Brian Bee, The Knowledge Warehouse Ltd

Presented at SEUGI '92 by Colin Harris,SAS Institute

(c) What is the result of running the following program? x = 3 f = function (y){y+x} g = function (y){x =10; f(y)} g (7) Solution: The result is 10.

Chapter 2: Getting Data Into SAS

I L L I N O I S UNIVERSITY OF ILLINOIS AT URBANA-CHAMPAIGN

SAS seminar. The little SAS book Chapters 3 & 4. April 15, Åsa Klint. By LD Delwiche and SJ Slaughter. 3.1 Creating and Redefining variables

SAS PROGRAMMING AND APPLICATIONS (STAT 5110/6110): FALL 2015 Module 2

Ten Great Reasons to Learn SAS Software's SQL Procedure

Structured Programming. Dr. Mohamed Khedr Lecture 4

Google Docs: Spreadsheet basics

ADP Reporting Skills Business Requirements ADP Pro User Conference

PROC MEANS for Disaggregating Statistics in SAS : One Input Data Set and One Output Data Set with Everything You Need

SAS 101. Based on Learning SAS by Example: A Programmer s Guide Chapter 21, 22, & 23. By Tasha Chapman, Oregon Health Authority

Stat 302 Statistical Software and Its Applications SAS: Data I/O

Script.byu.edu SharePoint Instructions

DEBUGGING SERIAL COMMUNICATIONS WITH OTHER DEVICES

Introduction to Stata Getting Data into Stata. 1. Enter Data: Create a New Data Set in Stata...

Cody s Collection of Popular SAS Programming Tasks and How to Tackle Them

Introduction to SAS Procedures SAS Basics III. Susan J. Slaughter, Avocet Solutions

22S:166. Checking Values of Numeric Variables

Intermediate SAS: Working with Data

Lecture 1 Getting Started with SAS

DSCI 325: Handout 4 If-Then Statements in SAS Spring 2017

Homework 1 Excel Basics

22/10/16. Data Coding in SPSS. Data Coding in SPSS. Data Coding in SPSS. Data Coding in SPSS

CHAPTER 13 Importing and Exporting External Data

Downloading 2010 Census Data

Using a HASH Table to Reference Variables in an Array by Name. John Henry King, Hopper, Arkansas

Introduction to C programming. By Avani M. Sakhapara Asst Professor, IT Dept, KJSCE

Getting Up to Speed with PROC REPORT Kimberly LeBouton, K.J.L. Computing, Rossmoor, CA

Basic Operations and Equivalent Expressions - Step-by-Step Lesson

2. Don t forget semicolons and RUN statements The two most common programming errors.

EXST SAS Lab Lab #8: More data step and t-tests

Week 3 Lecture 2. Types Constants and Variables

QDS v5.0 New Features Documentation

IENG484 Quality Engineering Lab 1 RESEARCH ASSISTANT SHADI BOLOUKIFAR

CPE Summer 2015 Exam I (150 pts) June 18, 2015

Learn to Impress - Hidden base SAS features. Peter Crawford Crawford Software Consultancy Limited 1 of 21

Google Sheets: Spreadsheet basics

An Animated Guide: Proc Transpose

Reading data in SAS and Descriptive Statistics

Department of Economics Spring 2016 University of California Economics 154 Professor Martha Olney Stata Lesson Wednesday February 17, 2016

Entering and Managing Data in EvaluationWeb for CDC Program Announcement PS

TYPES OF VARIABLES, STRUCTURE OF DATASETS, AND BASIC STATA LAYOUT

Opening a Data File in SPSS. Defining Variables in SPSS

Chapter 6 Creating Reports. Chapter Table of Contents

Your First Windows Form

1. Creating a data set using the data editor 2. Importing an Excel data file

SAS Training Spring 2006

using and Understanding Formats

Macros are a block of code that can be executed/called on demand

Mr. Kongmany Chaleunvong. GFMER - WHO - UNFPA - LAO PDR Training Course in Reproductive Health Research Vientiane, 22 October 2009

Econ Stata Tutorial I: Reading, Organizing and Describing Data. Sanjaya DeSilva

Successmaker Student and Teacher Imports

Select Cases. Select Cases GRAPHS. The Select Cases command excludes from further. selection criteria. Select Use filter variables

For many people, learning any new computer software can be an anxietyproducing

STAT:5400 Computing in Statistics

BEYOND FORMAT BASICS 1

Epidemiology Principles of Biostatistics Chapter 3. Introduction to SAS. John Koval

SYSTEM 2000 Essentials

Entering and Managing Data in EvaluationWeb for CDC Program Announcement PS

Formats. Formats Under UNIX. HEXw. format. $HEXw. format. Details CHAPTER 11

Frequency Tables. Chapter 500. Introduction. Frequency Tables. Types of Categorical Variables. Data Structure. Missing Values

The INPUT Statement: Where

STAT10010 Introductory Statistics Lab 2

3. Almost always use system options options compress =yes nocenter; /* mostly use */ options ps=9999 ls=200;

Quality Control of Clinical Data Listings with Proc Compare

Surviving SPSS.

Create a Questionnaire. Triangle

It s Proc Tabulate Jim, but not as we know it!

Formats, Informats and How to Program with Them Ian Whitlock, Westat, Rockville, MD

Installation Instructions for: Channel Thermocouple Amplifier

Biology 345: Biometry Fall 2005 SONOMA STATE UNIVERSITY Lab Exercise 2 Working with data in Excel and exporting to JMP Introduction

16. Reading raw data in fixed fields. GIORGIO RUSSOLILLO - Cours de prépara)on à la cer)fica)on SAS «Base Programming» 364

Week 6, Week 7 and Week 8 Analyses of Variance

UPGRADE AND CONVERT INSTRUCTION Not available on the ipad. This step must be done on your computer and then transfer your files to ipad.

TURNING MOVEMENT CALCULATOR VERSION 3.0

Signed umbers. Sign/Magnitude otation

A Practical Introduction to SAS Data Integration Studio

Special Topics for Embedded Programming

Teach Yourself Microsoft Word Topic 12 - Multipage Document Features Part 1

29 Shades of Missing

Chapter 6: Modifying and Combining Data Sets

LAB 1: Graphical Descriptions of Data

PIVOT TABLES IN MICROSOFT EXCEL 2016

Appendix A. SPSS 11.x in 30 Minutes

MATH 707-ST: Introduction to Statistical Computing with SAS and R. MID-TERM EXAM (Writing part) Fall, (Time allowed: TWO Hours)

Anonymization Case Study 1: Randomizing Names and Addresses

GET A GRIP ON MACROS IN JUST 50 MINUTES! Arthur Li, City of Hope Comprehensive Cancer Center, Duarte, CA

ASSIGNMENT #2 ( *** ANSWERS ***) 1

Superior University. Department of Electrical Engineering CS-115. Computing Fundamentals. Experiment No.7. User Defined Functions II

Using Dynamic Data Exchange

Statistical Analysis Using Minitab

MAKING TABLES WITH WORD BASIC INSTRUCTIONS. Setting the Page Orientation. Inserting the Basic Table. Daily Schedule

Transcription:

ERROR: ERROR: ERROR:

Formatting Variables: Back and forth between character and numeric

Why should you care? DATA name1; SET name; if var = Three then delete; if var = 3 the en delete; if var = 3 then delete; RUN; NOTE: Character values have been converted to numeric values at the places given by: (Line):(Column).

Why should you care? DATA name1; SET name; if var = Three then delete;; if var = 3 the en delete; if var = 3 then delete; RUN; NOTE: Character values have been converted to numeric values at the places given by: (Line):(Column).

Why should you care? DATA name1; SET name; if var = Three then delete; if var = 3 the en delete; if var = 3 then delete; RUN; NOTE: Character values have been converted to numeric values at the places given by: (Line):(Column).

Why should you care? DATA name1; SET name; if var = Three then delete; if var = 3 the en delete; if var = 3 then delete; RUN; NOTE: Character values have been converted to numeric values at the places given by: (Line):(Column).

Why should you care? DATA name1; SET name; if var = Three then delete; if var = 3 the en delete; if var = 3 then delete; RUN; OK NOTE: Character values have been converted to numeric values at the places given by: (Line):(Column).

Why should you care? DATA name1; SET name; if var = Three then delete; if var = 3 the en delete; if var = 3 then delete; RUN; OK NOTE: Character values have been converted to numeric values at the places given by: (Line):(Column).

PROBLEM: Identify the same variable as character and numeric SAS attempts to make them comparable Character Numeric Implicit coding Should avoid SAS is making the decisions s not you Opportunity to introduce errors FRUSTRATION!

Know the current format of your data. PROC CONTE ENTS; RUN;

SAS Enterprise Guide

Regular SAS CHAR CHAR NUM CHAR CHAR

How do I decide what format my variable should be?

Selecting the best format Obvious choices if a variable contains non-numeric information character If a variable contains numeric data numeric Not so obvious choices Integer data that won t be ID Number = 1757638 Nominal variables Sex: 1 = Male, 2 = Female used in any calculations Use numeric variables whenever possible Eliminates leading and trailing blanks

Now that I know what format I want, how do make it happen?

INFORMATS FORM MATS INPUT & PUT statements

Tells SAS how to read data from external files into SAS variables INFORMAT Changes how the variable is presented but does not change the variable itself Instructions for outputting data FORMAT Non-SAS input file SAS data aset Output INPUT statement PUT statement

INFORMAT DATA name; Infile C:/My Files/Jacq ; informat VAR1 $8.; informat VAR2 4.1; input VAR1 $ VAR2 ; RUN;

Numeric examples 4.1 COMMA10. HEX4. Character examples $CHAR10. $10. $HEX4.

FORMAT PROC FORMAT; value gender 1 2 RUN; = Male = Female ; PROC PRINT; VAR var_name; FORMAT var_name gender.; RUN;

FORMAT PROC FORMAT; value gender 1 2 RUN; = Male = Female ; PROC PRINT; VAR var_name; FORMAT var_name gender.; RUN;

FORMAT PROC FORMAT; value $gender M = Male F = Female ; RUN; PROC PRINT; VAR var_name; FORMAT var_name $gender.; RUN;

FORMAT PROC FORMAT; value $gender M = Male F = Female ; RUN; PROC PRINT; VAR var_name; FORMAT var_name $gender.; RUN;

INPUT & PUT Statements INPUT - converts character to numeric PUT - converts numeric to character Not possible to directly change the type of variable Must create new variable Rename Drop

DATA data1; SET data; /*Character to numeric */ new_num=input(char_var,$4); /* Numeric to character */ new_char=put(num_var,4.0); RUN;

In sum.

What format should you use when the choice is not obvious? NUMERIC Why? Don t have to worry about leading or trailing blanks

Know the current format of your data. 1. PROC CONTENTS 2. Enterprise Guide SA AS - Numeric - blue circles - Character - red triangles 3. REGULAR SAS - Numeric right justified - Character left justified

INFORMAT FORMAT Non-SAS input file? SAS data aset? Output? INPUT statement PUT statement

NOTE: The data set COPD.MASTER has 14,295 observations and 23 variables