BIOMETRICS INFORMATION

Similar documents
Using GSUBMIT command to customize the interface in SAS Xin Wang, Fountain Medical Technology Co., ltd, Nanjing, China

Using an ICPSR set-up file to create a SAS dataset

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

Use That SAP to Write Your Code Sandra Minjoe, Genentech, Inc., South San Francisco, CA

Chapter 2: Getting Data Into SAS

DSCI 325: Handout 2 Getting Data into SAS Spring 2017

Importing CSV Data to All Character Variables Arthur L. Carpenter California Occidental Consultants, Anchorage, AK

An Automation Procedure for Oracle Data Extraction and Insertion

A SAS Macro for Producing Benchmarks for Interpreting School Effect Sizes

Problem 1. Remove consecutive duplicates (6 points, 11 mintues)

Top Coding Tips. Neil Merchant Technical Specialist - SAS

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

The DATA Statement: Efficiency Techniques

FSEDIT Procedure Windows

PROC FORMAT. CMS SAS User Group Conference October 31, 2007 Dan Waldo

April 4, SAS General Introduction

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

STAT 7000: Experimental Statistics I

SAS Drug Development Program Portability

Contents of SAS Programming Techniques

Paper SAS Programming Conventions Lois Levin, Independent Consultant, Bethesda, Maryland

General Tips for Working with Large SAS datasets and Oracle tables

Accessing Data and Creating Data Structures. SAS Global Certification Webinar Series

Prove QC Quality Create SAS Datasets from RTF Files Honghua Chen, OCKHAM, Cary, NC

Tips & Tricks. With lots of help from other SUG and SUGI presenters. SAS HUG Meeting, November 18, 2010

SAS Online Training: Course contents: Agenda:

SUGI 29 Data Warehousing, Management and Quality

Level I: Getting comfortable with my data in SAS. Descriptive Statistics

;... _... name; tsoge. scr purpose: Startup a TSO SAS session. notes: Assumes the TSO session has been logged on manually.

Contents. Overview How SAS processes programs Compilation phase Execution phase Debugging a DATA step Testing your programs

Dictionary.coumns is your friend while appending or moving data

Posters. Paper

Base and Advance SAS

SAS Programming Conventions Lois Levin, Independent Consultant

SAS Viya 3.1 FAQ for Processing UTF-8 Data

Automated Checking Of Multiple Files Kathyayini Tappeta, Percept Pharma Services, Bridgewater, NJ

Objectives Reading SAS Data Sets and Creating Variables Reading a SAS Data Set Reading a SAS Data Set onboard ia.dfwlax FirstClass Economy

Developing Data-Driven SAS Programs Using Proc Contents

Exponential Numbers ID1050 Quantitative & Qualitative Reasoning

SAS Graphics & Code. stat 480 Heike Hofmann

Moving Data and Results Between SAS and Excel. Harry Droogendyk Stratia Consulting Inc.

Overview of Data Management Tasks (command file=datamgt.sas)

Reading in Data Directly from Microsoft Word Questionnaire Forms

TIPS AND TRICKS: IMPROVE EFFICIENCY TO YOUR SAS PROGRAMMING

Global Model Workstation Release Log

Using Dynamic Data Exchange

Chapter 6: Modifying and Combining Data Sets

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

Using Maps with the JSON LIBNAME Engine in SAS Andrew Gannon, The Financial Risk Group, Cary NC

ODS DOCUMENT, a practical example. Ruurd Bennink, OCS Consulting B.V., s-hertogenbosch, the Netherlands

Procedure for Stamping Source File Information on SAS Output Elizabeth Molloy & Breda O'Connor, ICON Clinical Research

Numeric Variable Storage Pattern

Beginning Tutorials DATE HANDLING IN THE SAS SYSTEM. Bruce Gilsen, Federal Reserve Board

ABSTRACT INTRODUCTION THE GENERAL FORM AND SIMPLE CODE

INTRODUCTION TO SAS HOW SAS WORKS READING RAW DATA INTO SAS

Introduction to SAS. Cristina Murray-Krezan Research Assistant Professor of Internal Medicine Biostatistician, CTSC

A Macro To Generate a Study Report Hany Aboutaleb, Biogen Idec, Cambridge, MA

Procedures. PROC CATALOG CATALOG=<libref.>catalog <ENTRYTYPE=etype> <KILL>; CONTENTS <OUT=SAS-data-set> <FILE=fileref;>

Integrating Large Datasets from Multiple Sources Calgary SAS Users Group (CSUG)

Electricity Forecasting Full Circle

Using DDE with Microsoft Excel and SAS to Collect Data from Hundreds of Users

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

17. Reading free-format data. GIORGIO RUSSOLILLO - Cours de prépara)on à la cer)fica)on SAS «Base Programming» 386

A Macro that Creates U.S Census Tracts Keyhole Markup Language Files for Google Map Use

Chapter 1 The DATA Step

SAS CURRICULUM. BASE SAS Introduction

A SAS Macro Utility to Modify and Validate RTF Outputs for Regional Analyses Jagan Mohan Achi, PPD, Austin, TX Joshua N. Winters, PPD, Rochester, NY

Assembler Language "Boot Camp" Part 2 - Instructions and Addressing SHARE 116 in Anaheim February 28, 2011

Increase Defensiveness of Your Code: Regular Expressions

Open Problem for SUAVe User Group Meeting, November 26, 2013 (UVic)

The NESTED Procedure (Chapter)

work.test temp.test sasuser.test test

Photos with Text Reports on the Same SAS/AF Screen

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

Macro Method to use Google Maps and SAS to Geocode a Location by Name or Address

Copy That! Using SAS to Create Directories and Duplicate Files

DSCI 325 Practice Midterm Questions Spring In SAS, a statement must end

Using Different Methods for Accessing Non-SAS Data to Build and Incrementally Update That Data Warehouse

PDF Multi-Level Bookmarks via SAS

AURA ACADEMY SAS TRAINING. Opposite Hanuman Temple, Srinivasa Nagar East, Ameerpet,Hyderabad Page 1

Program Validation: Logging the Log

Creating and Executing Stored Compiled DATA Step Programs

Introduction to SAS. Hsueh-Sheng Wu. Center for Family and Demographic Research. November 1, 2010

Fundamentals of Programming

How to use UNIX commands in SAS code to read SAS logs

Macros I Use Every Day (And You Can, Too!)

TASS Interfaces Open Question

PASS4TEST. IT Certification Guaranteed, The Easy Way! We offer free update service for one year

CHAPTER 7 Using Other SAS Software Products

Make Your Life a Little Easier: A Collection of SAS Macro Utilities. Pete Lund, Northwest Crime and Social Research, Olympia, WA

8/30/2016. In Binary, We Have A Binary Point. ECE 120: Introduction to Computing. Fixed-Point Representations Support Fractions

So Much Data, So Little Time: Splitting Datasets For More Efficient Run Times and Meeting FDA Submission Guidelines

Preserving your SAS Environment in a Non-Persistent World. A Detailed Guide to PROC PRESENV. Steven Gross, Wells Fargo, Irving, TX

USING SAS SOFTWARE TO COMPARE STRINGS OF VOLSERS IN A JCL JOB AND A TSO CLIST

Chapter 7 File Access. Chapter Table of Contents

Using a Fillable PDF together with SAS for Questionnaire Data Donald Evans, US Department of the Treasury

Introductory Guide to SAS:

PASS4TEST. IT Certification Guaranteed, The Easy Way! We offer free update service for one year

A Macro that can Search and Replace String in your SAS Programs

Center For Emergency Response and Public Safety

Transcription:

BIOMETRICS INFORMATION (You re 95% likely to need this information) PAMPHLET NO. # 24 DATE: February 9, 1990 SUBJECT: Reading WATFILE files into SAS WATFILE is a useful package for data entry because it is easy to use. But it is annoying to define variable names and formats twice -- once for WATFILE and again for SAS. To avoid this duplication I wrote a SAS program that reads the variable names and formats defined in WATFILE and creates a SAS data step to read in the data. This program is called WATREAD.sas. A copy of the program is attached to this pamphlet 1. To avoid typing, you may send me a diskette which will be returned bearing a copy of the program. Use these steps for WATFILE data entry: 1. Sign onto WATFILE. (If you are unfamiliar with WATFILE you may find the HELP command, or the F1 key, useful). 2. Use the DEFINE statement to: i) Name the variables. ii) Indicate whether they are character or numeric. iii) Define their length and, if numeric, the number of decimal places. Decimal values will be truncated if the number of places indicated is less than the number input. and iv) Optionally, set limits on allowable values for each variable. 3. Type in data. 4. Save a file in WATFILE format by using SAVE filename (the file will be stored in DOS without an extension as filename. ). 5. Start a SAS session by typing in SAS. 6. On the command line type in: INC 'WATREAD.SAS'. CHANGE 'inptdata' 'filename' ALL (This step is necessary with the original program.) (you should see 11 occurrences changed). SUBMIT or press F10. 7. When WATREAD.sas has finished, the program window will contain the data step for reading in the data. Type in SUBMIT or press F10 to start the process. Some changes you might want to make to the program before submitting are: i) Change the data step name to a two-level name so that a permanent dataset is created. Don't forget to add the appropriate LIBNAME statement before the data step. If you put this LIBNAME statement in the AUTOEXEC.SAS file then it is already established when 1 Ron Kozsan has since improved this program by using SAS MACRO's. See System Information pamphlet #25. His program is on pages 3 and 4 while the original is on pages 5 and 6. Ministry of Forests Research Program

2 you start typing in SAS commands. ii) Change the format of some of the variables. For instance: a) If you used missing values such as '.', 'D' or'm' for numeric data, you will have had to define those variables as character. WATFILE will not let you enter values such as 'D' or 'M' in numeric fields and changes '.' to zero (0)! In this case you will want to delete the '$' occurring after the name of the variable so that SAS will read it as numeric. b) If you used implicit decimal points in your data you will want to change the format from w. to w.d (this is SAS format notation, where w is the width of the field or total number of digits, and d indicates the number of decimal places). The w. format does not have to be changed for data with explicit decimal points. Hence, if you have typed in the decimal place you will not need to make this change. iii) You may also want to create new variables as functions of the ones you have read in. If so, put the corresponding statements in after the /* End of INPUT statement */ and before the RUN; statement. iv) Add titles, labels, your own formats (with PROC FORMAT) and/or assign new formats with a FORMAT statement. v) Your other SAS code to analyze the data. When setting up the file in WATFILE, note the following. 1. Variable names should be 8 digits or less in length for SAS. Since they can be up to 20 characters long in WATFILE, the program will truncate them to the first 8. So, if you do use longer names keep the first 8 characters unique for each variable or workspace field. 2. WATFILE changes values of '.' to zero in numeric fields. Missing values can be left blank and SAS will read them correctly. 3. WATFILE does not allow any alphabetic characters in numeric fields. 4. WATFILE can be set up to check for incorrect values. This is particularly easy to do for numeric variables and one-digit character variables. See Chapter III.1.3 of the WATFILE manual. Reference: Wilkinson, Terry. 1987. WATFILE/Plus data manipulation system: Tutorial and Reference, 3rd ed., WATCOM Publications Ltd., Waterloo, Ontario. CONTACT: Wendy Bergerud 387-5676

/* Watread.sas */ /* New program as of July, 1995 */ %let watfile= ; %let pgmfile= ; %let ssdfile= ; 3 Pamphlet #24 rrrrrrrrrrrrrrrrrrrrr %window watread color=cyan #1 @5 'Welcome to the interactive Watread Program.' color=red #3 @12 ' * Utility to convert Watfile database *' color=blue #4 @12 ' * files to SAS data sets *' color=blue #8 @9 "Please enter the names of:" #10 @16 "Watfile data file :" @39 watfile 40 attr=underline required=yes color=blue #12 @16 "SAS program file :" @39 pgmfile 12 attr=underline required=yes color=blue #13 @16 " (to be created) " #15 @16 "SAS data set :" @43 ssdfile 8 attr=underline required=yes color=blue #16 @16 " (to be created) "; %display watread; /*==== DATASTEP INITIALIZATION ====*/ data _null_; infile "&watfile" missover ; *<=====INPUT DATA FILE========; file "&pgmfile" lrecl = 100; *<=====OUTPUT PGM FILE========; retain frst add 0 col 1 inp1-inp70 number; length col 4 var $ 8 type $ 1 length 4 inp1-inp69 $ 80 inp70 $ 69; array inp {70} $ inp1-inp70; /*==== READING THE WATFILE COLUMN DEFINITIONS ====*/ input first $ 1-3 @; line + 1; if _n_ = 1 then frst=line; *<====START OF FILE=======; /* if first ='% S' then do; add = 1; return; end; */ if (substr(first,1,1) = '%') or first = 'tit' then do; *<====WATFILE COMMENTS====; add + 1; return; end; if first = 'def' then do; *<====COLUMN DEFINITIONS==; input var $ 8-25 digit 30-32 decimal 34 type $ 36; if type = 'L' or type = 'R' then type = '$'; **Character vars; else type=' '; ***Numeric vars; if decimal =. then length = digit; else length = digit + decimal + 1; var = substr(var,1,8); *** Shortening var names to 8 digits; /*==== FORMING THE LINES OF THE INPUT STATEMENT ====*/ inp{70} = col ' ' var ' ' type ' ' length '.'; if line = frst + add then do; **First line of INPUT statement; number=4; inp{number} = '/**/input @' inp{70}; end; else do; **Other lines of INPUT statement; number + 1; inp{number} = '/**/ @' inp{70}; end; col + length; output; return; end;

4 /*==== AT END OF WATFILE COLUMN DEFINITIONS ====*/; if first = 'bye' then do; col + length; /*=== FORMING THE FIRST THREE LINES OF PROGRAM ===*/ inp1 = "Data &ssdfile ; "; *<====SAS DATA SET NAME=======; inp2 = " infile '&watfile'"; *<====WATFILE TO BE READ======; inp3 = "/**/missover " "firstobs = " line+1 " lrecl = " col ";" ; /*==== OUTPUTTING PROGRAM STATEMENTS =====*/ put "TITLE1 'Reading in data from &watfile ';"; do i = 1 to number; put inp{i}; end; put ";;; /* End of INPUT statement */ ;;;"; put ""; output; stop; end; else return; /*==== MOVING PROGRAM TO WINDOW AND MAKING SOME MINOR CHANGES ====*/ dm "inc '&pgmfile'"; dm "change '@ ' '@' all"; dm "change '= ' '=' all"; dm "change ' ' ' ' all"; dm "change ' ' ' ' all"; dm "change '/**/' ' ' all"; dm "file '&pgmfile' replace "; dm "top; zoom on;"; PROBLEMS FROM BI #23ss 1. You should get the same answer. 2. For the second contrast (with coefficients: -7, -2, 3, 3, 3) the correlation coefficient is 0.919 and the SSC is.919 2 (4000) = 3380. Thus the F-value is 3380/500 = 6.76. If you reverse the order of the coefficients the correlation coefficient becomes -0.778 with an SSC of 2420. Thus both the value and the sign of the correlation changes implying that the patterns fit are different when the order is reversed. While the correlation for the linear contrast changes sign when the order is reversed, the value and corresponding SSC do not change, implying that the fundamental pattern fit is the same. 3. The present coefficients: 1 3 5 5 4 3 have a mean of 21/6. So multiply by 2 (to avoid fractions): to get coefficients: 2 6 10 10 8 6 with a mean of 7. Then subtract the mean of 7 so that the final coefficients: -5-1 3 3 1-1 have a mean of 0.

5 Pamphlet #24 rrrrrrrrrrrrrrrrrrrrr /* Watread.sas */ /* Original program */ /* Creating a SAS data step from a Watfile */ /* This program requires three changes: 1. Change 'inptdata.' to the name of your WATFILE file. 2. Change 'inptdata.inp' to a name for your output program file. 3. Change 'inptdata' to a name for the SAS dataset you want to create. -- the SAS dataset name can be either temporary (one-level name) or permanent (a two-level name). Note: if the names are all the same (and you did not use an extension when saving the file in WATFILE) then use: Change 'inptdata' 'example' all on the command line to make the changes. */ /*==== DATASTEP INITIALIZATION ====*/ data _null_; infile 'inptdata.' missover ; *<=====INPUT DATA FILE========; file 'inptdata.inp' ; *<=====OUTPUT PGM FILE========; retain frst add 2 col 1 inp1-inp70; length col 4 var $ 8 type $ 1 length 4 inp1-inp69 $ 80 inp70 $ 69; array inp {70} $ inp1-inp70; /*==== READING THE WATFILE COLUMN DEFINITIONS ====*/ input first $ 1-3 @; line + 1; if first ='%WA' then do; frst=line; *<====START OF FILE=======; line + 1; return; end; if (substr(first,1,1) = '%') then do; *<====WATFILE COMMENTS====; add + 1; return; end; if first = 'def' then do; *<====COLUMN DEFINITIONS==; input var $ 8-25 digit 30-32 decimal 34 type $ 36; if type = 'L' or type = 'R' then type = '$'; **Character vars; else type=' '; ***Numeric vars; if decimal =. then length = digit; else length = digit + decimal + 1; var = substr(var,1,8); *** Shortening var names to 8 digits; /*==== FORMING THE LINES OF THE INPUT STATEMENT ====*/ inp{70} = col ' ' var ' ' type ' ' length '.'; if line = frst + add then do; **First line of INPUT statement; number=4; inp{number} = '/**/input @' inp{70}; end; else do; **Other lines of INPUT statement; number + 1; inp{number} = '/**/ @' inp{70}; end; col + length; return; end;

6 /*==== AT END OF WATFILE COLUMN DEFINITIONS ====*/; if first = 'bye' then do; col + length; /*=== FORMING THE FIRST THREE LINES OF PROGRAM ===*/ inp1 = "Data inptdata ; "; *<====SAS DATA SET NAME=======; inp2 = " infile 'inptdata.'"; *<====WATFILE TO BE READ======; inp3 = "/**/missover " "firstobs = " line " lrecl = " col ";" ; /*==== OUTPUTTING PROGRAM STATEMENTS =====*/ do i = 1 to number; put # i inp{i}; end; put ";;; /* End of INPUT statement */ ;;;"; put "TITLE1 'Reading in data from inptdata. ';"; put ""; stop; end; /*==== MOVING PROGRAM TO WINDOW AND MAKING SOME MINOR CHANGES ====*/ dm "inc 'inptdata.inp'"; dm "change ' ' '' all"; dm "change '/**/' ' ' all "; dm "file 'inptdata.inp'"; dm "top; zoom on;"; /*==== SAS INPUT PROGRAM NOW READY TO RUN ====*/