Different Decimal Places For Different Laboratory Tests PharmaSug 2004, TT01 A. Cecilia Mauldin.

Slides:



Advertisements
Similar presentations
Statistical Methods Lynne Stokes Department of Statistical Science Lecture 7: Introduction to SAS Programming Language.
Advertisements

Examples from SAS Functions by Example Ron Cody
Slide C.1 SAS MathematicalMarketing Appendix C: SAS Software Uses of SAS  CRM  datamining  data warehousing  linear programming  forecasting  econometrics.
Combining Lags and Arrays [and a little macro] Lynn Lethbridge SHRUG OCT 28, 2011.
Outline Proc Report Tricks Kelley Weston. Outline Examples 1.Text that spans columnsText that spans columns 2.Patient-level detail in the titlesPatient-level.
I OWA S TATE U NIVERSITY Department of Animal Science Modifying and Combing SAS Data Sets (Chapter in the 6 Little SAS Book) Animal Science 500 Lecture.
SAS Programming: Working With Variables. Data Step Manipulations New variables should be created during a Data step Existing variables should be manipulated.
I OWA S TATE U NIVERSITY Department of Animal Science Getting Started Using SAS Software Animal Science 500 Lecture No. 2.
Beginning Data Manipulation HRP Topic 4 Oct 19 th 2011.
CMP 131 Introduction to Computer Programming Violetta Cavalli-Sforza Week 2, Lecture 2.
Quick Data Summaries in SAS Start by bringing in data –Use permanent data set for these examples Proc Tabulate –Produces summaries very quickly and easily.
Introduction to SQL Session 1 Retrieving Data From a Single Table.
Basic And Advanced SAS Programming
Let SAS Do the Coding for You! Robert Williams Business Info Analyst Sr. WellPoint Inc.
PROC_CODEBOOK: An Automated, General Purpose Codebook Generator
Data Cleaning 101 Ron Cody, Ed.D Robert Wood Johnson Medical School Piscataway, NJ.
Welcome to SAS…Session..!. What is SAS..! A Complete programming language with report formatting with statistical and mathematical capabilities.
FORMAT FESTIVAL AN INTRODUCTION TO SAS® FORMATS AND INFORMATS By David Maddox.
SAS SQL SAS Seminar Series
Lecture 5 Sorting, Printing, and Summarizing Your Data.
SAS Workshop Lecture 1 Lecturer: Annie N. Simpson, MSc.
Introduction to SAS Essentials Mastering SAS for Data Analytics Alan Elliott and Wayne Woodward SAS ESSENTIALS -- Elliott & Woodward1.
1 Experimental Statistics - week 4 Chapter 8: 1-factor ANOVA models Using SAS.
Niraj J. Pandya, Element Technologies Inc., NJ.  Summarize all possible combinations of class level variables even if few categories are altogether missing.
PROC SQL Phil Vecchione. SQL Structured Query Language Developed by IBM in the early 1970’s From the 70’s to the late 80’s there were different types.
SAS ® PROC SQL or Vanilla Flavor Cecilia Mauldin January
SAS Efficiency Techniques and Methods By Kelley Weston Sr. Statistical Programmer Quintiles.
SQL Chapter Two. Overview Basic Structure Verifying Statements Specifying Columns Specifying Rows.
1 Efficient SAS Coding with Proc SQL When Proc SQL is Easier than Traditional SAS Approaches Mike Atkinson, May 4, 2005.
ISU Basic SAS commands Laboratory No. 1 Computer Techniques for Biological Research Animal Science 500 Ken Stalder, Professor Department of Animal Science.
Summer SAS Workshop Lecture 2. Summer Summer SAS Workshop Lecture 2 I’ve got Data…how do I get started? Libname Review How do you do arithmetic.
Lesson 6 - Topics Reading SAS datasets Subsetting SAS datasets Merging SAS datasets.
Chapter 22: Using Best Practices 1 STAT 541 ©Spring 2012 Imelda Go, John Grego, Jennifer Lasecki and the University of South Carolina.
© OCS Biometric Support 1 APPEND, EXECUTE and MACRO Jim Groeneveld, OCS Biometric Support, ‘s Hertogenbosch, Netherlands. PhUSE 2010 – CC05 PhUSE 2010.
Tips & Tricks From your fellow SAS users 9/30/2004.
SAS Basics. Windows Program Editor Write/edit all your statements here. Log Watch this for any errors in program as it runs. Output Will automatically.
Chapter 4 concerns various SAS procedures (PROCs). Every PROC operates on: –the most recently created dataset –all the observations –all the appropriate.
YET ANOTHER TIPS, TRICKS, TRAPS, TECHNIQUES PRESENTATION: A Random Selection of What I Learned From 15+ Years of SAS Programming John Pirnat Kaiser Permanente.
Lesson 8 - Topics Creating SAS datasets from procedures Using ODS and data steps to make reports Using PROC RANK Programs in course notes LSB 4:11;5:3.
SAS Basics. Windows Program Editor Write/edit all your statement here.
SAS for Data Management and Analysis
An Introduction Katherine Nicholas & Liqiong Fan.
SAUSAG 69 – 20 Feb 2014 Smarter Sorts Jerry Le Breton (Softscape Solutions) & Doug Lean (DHS) Beyond the Obvious.
Computing with SAS Software A SAS program consists of SAS statements. 1. The DATA step consists of SAS statements that define your data and create a SAS.
FORMAT statements can be used to change the look of your output –if FORMAT is in the DATA step, then the formats are permanent and stored with the dataset.
Copyright © 2004, SAS Institute Inc. All rights reserved. SASHELP Datasets A real life example Barb Crowther SAS Consultant October 22, 2004.
Customize SAS Output Using ODS Joan Dong. The Output Delivery System (ODS) gives you greater flexibility in generating, storing, and reproducing SAS procedure.
HRP Copyright © Leland Stanford Junior University. All rights reserved. Warning: This presentation is protected by copyright law and.
BMTRY 789 Lecture 6: Proc Sort, Random Number Generators, and Do Loops Readings – Chapters 5 & 6 Lab Problem - Brain Teaser Homework Due – HW 2 Homework.
Use the SET statement to: –create an exact copy of a SAS dataset –modify an existing SAS dataset by creating new variables, subsetting (using a subsetting.
SHRUG, F EB 2013: N ETWORKING EXERCISE Many Ways to Solve a SAS Problem.
Chapter 6: Modifying and Combining Data Sets  The SET statement is a powerful statement in the DATA step DATA newdatasetname; SET olddatasetname;.. run;
Beginning Data Manipulation HRP Topic 4 Oct 14 th 2012 Copyright © Leland Stanford Junior University. All rights reserved. Warning: This.
Based on Learning SAS by Example: A Programmer’s Guide Chapters 1 & 2
Online Programming| Online Training| Real Time Projects | Certifications |Online Classes| Corporate Training |Jobs| CONTACT US: STANSYS SOFTWARE SOLUTIONS.
Copyright 2009 The Little Engine That Could: Using EXCEL LIBNAME Engine Options to Enhance Data Transfers between SAS® and Microsoft® Excel Files William.
Longitudinal Data Techniques: Looking Across Observations Ronald Cody, Ed.D., Robert Wood Johnson Medical School.
Better Metadata Through SAS® II: %SYSFUNC, PROC DATASETS, and Dictionary Tables.
SAS ® 101 Based on Learning SAS by Example: A Programmer’s Guide Chapters 16 & 17 By Tasha Chapman, Oregon Health Authority.
SAS ® 101 Based on Learning SAS by Example: A Programmer’s Guide Chapters 5 & 6 By Ravi Mandal.
Session 1 Retrieving Data From a Single Table
Applied Business Forecasting and Regression Analysis
Chapter 6: Modifying and Combining Data Sets
(or SASopardy, if you will)
Creating Macro Variables in the DATA Step
Lab 3 and HRP259 Lab and Combining (with SQL)
Hans Baumgartner Penn State University
Let’s review some of the statistics you’ve learned in your first class: Univariate analyses (single variable) are done both graphically and numerically.
Presentation transcript:

Different Decimal Places For Different Laboratory Tests PharmaSug 2004, TT01 A. Cecilia Mauldin

What is a Lab? What can be a problem? Different ways of solving the problem The data for these examples The PUTN function When should we be careful Calculating the width and number of decimal places The variable that is formatting is calculated Creating a table of laboratory results Final thoughts References Different Decimal Places for Different Lab Tests

What is a Lab? Laboratory Test Laboratory Result HCT PLT RDW WBC

What is a lab? A Lab Mix

What Can Be a Problem? When reporting results for listings, we do not need to format. We should present the data as it is received. Unless we want to present all the lab results from the same test with the same format But when doing tables, how many decimals should each laboratory test have for the mean? For the standard deviation?

Different Ways of Solving the Problem Every Lab test will use the same format All will have best. or best.2? All will have 10.2 We put as many “IF” statements as there are Lab tests We use select statements We use a macro variable for each test …

Different Ways of Solving the Problem We Use the values from a modified version of the LabNormal dataset or another dataset where the width and number of decimal places for each test is given and use the PUTN function.

The Modified LabNormal Dataset Lab Test Low Normal Value High Normal Values Created Format HCT PLT RDW WBC

The Data for this Examples data new; input LAB $ result ; cards; HCT HCT PLT PLT PLT RDW RDW RDW RDW WBC 4.0 WBC ; run; data useinfor; input lab $ frstf $ low high ; cards; HCT PLT RDW WBC ; run;

The Data for this Examples (both datasets were already sorted by lab); data toprint; merge new useinfor; by lab; run; proc print data=toprint; by lab; id lab; run;

LAB result frstf low high HCT PLT RDW WBC The Data for this Examples We did not select a format for the RESULT variable. SAS is using 7.3 (or 22.3) as the best way to print the results.

The PUTN Function title "Using PUTN with a format variable that already exists"; data firste; set toprint; formatm = putn( result, frstf); label formatm="FORMATM: value with format given by FRSTF" ; run;

The PUTN Function Using PUTN with a format variable that already exists FORMATM: value with format given LAB result frstf by FRSTF HCT PLT RDW WBC

The PUTN Function The PUTN Function’s structure is: NewVar=PUTN(Nres, FMT, width1, deci); Where: NRES is an existing Numeric Variable. In this example RESULT. FMT is an existing Character variable. In this example FRSTF. It has to be character because values that are acceptable are date., ddmmyy10., time5. … WIDTH1 is an Optional Numeric variable with final width of NewVar. DECI is an Optional Numeric variable with number of decimals included in NewVar

The Variable That Is Formatting Is Calculated The format of the output variable can depend on the value of the numeric result. If the result is smaller than the Normal Lower Limit (NLL) we will increase the number of decimals, if the result is bigger than the Normal Upper Limit (NUL) we will increase the width.

The Variable That Is Formatting Is Calculated title2 "Second Example"; title3 "the variable that is formatting is calculated"; data seconde; set toprint; if result< low then meanf=putn(result,put(input(frstf,best.) + 0.1,best.)); else if result>high then meanf=putn(result,put(input(frstf,best.) + 1.0,best.)); run;

The Variable That Is Formatting Is Calculated Second Example the variable that is formating is calculated LAB result low high frstf meanf HCT PLT Smaller than the LLV RDW WBC If you want to show 3 decimal places for , you need to have 6.3 Did you mean to round? Who decided rounding for you?

When representing data: Find the maximum number of decimals in each lab test. Decide Rounding and number of decimal presented depending in the number of decimals in your data.

Creating a Table of Lab Results The table that we want has: The Laboratory Lab Test, The Mean and Standard deviation for each test. The Mean is going to have one more decimal place than the maximum number of decimals reported by the lab.

Creating a Table of Lab Results The Standard Deviation is going to have two more decimal places than the maximum number of decimals reported by the lab.

Creating a Table of Lab Results Rounding should be done before any formatting takes place. This will help search for values with too many decimals or not enough decimal values. Time for an advertisement for Proc SQL.

Calculating the Width and Number of Decimal Places PROC SQL; CREATE TABLE LABS AS SELECT DISTINCT LAB, result, PUT(result,BEST.) AS CHAR FROM new ORDER BY lab ; The dataset LABS has the new variable CHAR, from where we can search for a decimal place and we can calculate the number of decimal places in each observation. CHAR HAS ALL THE DECIMAL PLACES IN RESULT.

Calculating the Width and Number of Decimal Places PROC SQL; CREATE TABLE DECIMAL AS SELECT DISTINCT LAB, MAX(LENGTH(CHAR)- INDEX(CHAR,'.')) AS DECIMAL FROM LABS WHERE CHAR LIKE '%.%' GROUP BY LAB ; SELECT * FROM DECIMAL; The dataset Decimal is the equivalent of our LabNormal dataset, there is one record for each Lab test with the maximum number of decimals for that test

Calculating the Width and Number of Decimal Places The Variable that will format is calculated LAB DECIMAL HCT 3 PLT 3 RDW 5 WBC 3

Calculating the Width and Number of Decimal Places CREATE TABLE DECIMAL AS SELECT DISTINCT LAB, DECIMAL, 10**(-DECIMAL -1) FORMAT BEST. AS ONERND, 10**(-DECIMAL -2) FORMAT BEST. AS TWORND, "32." ||PUT(DECIMAL +1,1.) AS ONEFMT, "32." ||PUT(DECIMAL +2,1.) AS TWOFMT FROM DECIMAL ; SELECT * FROM DECIMAL; QUIT;

Calculating the Width and Number of Decimal Places OneFMT is the value that has the maximum number of decimals plus one for each lab test. OneRnd is the value that has the number of decimals needed to round to one more decimal than the maximum number of decimals for each lab. TwoFMT is the value that has the maximum number of decimals plus one for each lab test. TwoRnd is the value that has the number of decimals needed to round to two more decimal than the maximum number of decimals for each lab.

Calculating the Width and Number of Decimal Places the variable that is formatting is calculated LAB DECIMAL ONERND TWORND ONEFMT TWOFMT HCT PLT RDW 5 1E-6 1E WBC

The everyday job… PROC UNIVARIATE DATA=LABS NOPRINT; VAR RESULT; BY lab; OUTPUT OUT=STAT MEAN=MEAN STD=STD; RUN; DATA FORMATED; MERGE STAT DECIMAL; BY LAB; RMEAN=ROUND(MEAN,ONERND); FMEAN=PUTN(RMEAN,ONEFMT); FSTD=PUTN(ROUND(STD,TWORND), TWOFMT); RUN;

The end! LAB MEAN STD DECIMAL RMEAN FMEAN FSTD HCT PLT RDW WBC Rmean: the r ounded mean. SAS is choosing the format for me. All the Labs have the same format. Fmean: the formatted, rounded mean. I chose the format and the rounding. FSTD: the formatted, rounded standard deviation

Final Thoughts This presentation focuses in using the PUTN function but the method that should be used will depend on the kind of job that will be done. Factors that should be considered are: Do you need do have different formats for different lab tests How many different Laboratory tests are going to be reported. How many statistics are required. Do you need to round. If yes, I would round first and then format.

Final Thoughts If you calculate the width and maximum number of decimal places, you will do a quick review of the data. get a handy tool to give the number of decimals. most of the time, just use 32 as the width. In this case, more is more.

References SAS Technical Report P-222. Changes and Enhancements to Base SAS Software. Release 6.07

Thank YOU for being here! Also Thanks to: Jim Nezamis for teaching me the PUTN function. LaTonya Murphy, Lan Tran and Terry Strader for reviewing my presentation. Bonnie Duncan and Kim Sturgen for their encouragement.

Contact Information This was a Power Pointer Mix Presentation A.Cecilia Mauldin 3900 Paramount Parkway Morrisville, NC Voice: (919)