1 / 34

Different Decimal Places For Different Laboratory Tests

Different Decimal Places For Different Laboratory Tests. PharmaSug 2004, TT01 A. Cecilia Mauldin. Different Decimal Places for Different Lab Tests. What is a Lab? What can be a problem? Different ways of solving the problem The data for these examples The PUTN function

Rita
Download Presentation

Different Decimal Places For Different Laboratory Tests

An Image/Link below is provided (as is) to download presentation Download Policy: Content on the Website is provided to you AS IS for your information and personal use and may not be sold / licensed / shared on other websites without getting consent from its author. Content is provided to you AS IS for your information and personal use only. Download presentation by click this link. While downloading, if for some reason you are not able to download a presentation, the publisher may have deleted the file from their server. During download, if you can't get a presentation, the file might be deleted by the publisher.

E N D

Presentation Transcript


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

  2. Different Decimal Places for Different Lab Tests • 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

  3. What is a Lab?

  4. What is a lab? A Lab Mix

  5. 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?

  6. 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…

  7. 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.

  8. The Modified LabNormal Dataset

  9. The Data for this Examples data new; input LAB $ result @@ ; cards; HCT 35.36 HCT 35.046 PLT 118.045 PLT 118.111 PLT 118.666 RDW 16.16 RDW 17.166 RDW 12.1666 RDW 12.16666 WBC 4.0 WBC 10.005 ; run; data useinfor; input lab $ frstf $ low high @@ ; cards; HCT 5.1 30 40 PLT 5.0 100 130 RDW 5.2 15 20 WBC 7.4 7 15 ; run;

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

  11. The Data for this Examples LAB result frstf low high HCT 35.360 5.1 30 40 35.046 5.1 30 40 PLT 118.045 5.0 100 130 118.111 5.0 100 130 118.666 5.0 100 130 RDW 16.160 5.2 15 20 17.166 5.2 15 20 12.167 5.2 15 20 12.167 5.2 15 20 WBC 4.000 7.4 7 15 10.005 7.4 7 15 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.

  12. 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;

  13. The PUTN Function Using PUTN with a format variable that already exists FORMATM: value with format given LAB result frstf by FRSTF HCT 35.360 5.1 35.4 35.046 5.1 35.0 PLT 118.045 5.0 118 118.111 5.0 118 118.666 5.0 119 RDW 16.160 5.2 16.16 17.166 5.2 17.17 12.167 5.2 12.17 12.167 5.2 12.17 WBC 4.000 7.4 4.0000 10.005 7.4 10.0050

  14. 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

  15. 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.

  16. 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;

  17. The Variable That Is Formatting Is Calculated Second Example the variable that is formating is calculated LAB result low high frstf meanf HCT 35.360 30 40 5.1 35.4 35.046 30 40 5.1 35.0 PLT 118.045 100 130 5.0 118 118.111 100 130 5.0 118 118.666 100 130 5.0 119 Smaller than the LLV RDW 16.160 15 20 5.2 16.16 17.166 15 20 5.2 17.17 12.167 15 20 5.2 12.17 12.167 15 20 5.2 12.17 WBC 4.000 7 15 7.4 4.00000 10.005 7 15 7.4 10.0050 Did you mean to round? Who decided rounding for you? If you want to show 3 decimal places for 12.167, you need to have 6.3

  18. 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.

  19. 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.

  20. 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.

  21. 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.

  22. Calculating the Width and Number of Decimal Places 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. PROCSQL; CREATE TABLE LABS AS SELECT DISTINCT LAB, result, PUT(result,BEST.) AS CHAR FROM new ORDER BY lab ;

  23. Calculating the Width and Number of Decimal Places PROCSQL; 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

  24. 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

  25. 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;

  26. 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.

  27. Calculating the Width and Number of Decimal Places the variable that is formatting is calculated LAB DECIMAL ONERND TWORND ONEFMT TWOFMT HCT 3 0.0001 0.00001 32.4 32.5 PLT 3 0.0001 0.00001 32.4 32.5 RDW 5 1E-6 1E-7 32.6 32.7 WBC 3 0.0001 0.00001 32.4 32.5

  28. The everyday job… PROCUNIVARIATE 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;

  29. The end! LAB MEAN STD DECIMAL RMEAN FMEAN FSTD HCT 35.203 0.22203 3 35.203 35.2030 0.22203 PLT 118.274 0.34108 3 118.274 118.2740 0.34108 RDW 14.415 2.62827 5 14.415 14.414815 2.6282669 WBC 7.003 4.24618 3 7.003 7.0025 4.24618 Rmean: the rounded 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

  30. 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.

  31. 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.

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

  33. 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.

  34. Contact Information • Cecilia Mauldin 3900 Paramount Parkway Morrisville, NC 27560 Voice: (919)462-4199 Cecilia.Mauldin@rtp.ppdi.com This was a Power Pointer Mix Presentation

More Related