Data Transformation Language (DTL)
Total Page:16
File Type:pdf, Size:1020Kb
DTL Data Transformation Language Phillip H. Sherrod Copyright © 2005-2006 All rights reserved www.dtreg.com DTL is a full programming language built into the DTREG program. DTL makes it easy to generate new variables, transform and combine input variables and select records to be used in the analysis. Contents Contents...................................................................................................................................................3 Introduction .............................................................................................................................................6 Introduction to the DTL Language......................................................................................................6 Using DTL For Data Transformations ....................................................................................................7 The main() function.............................................................................................................................7 Global Variables..................................................................................................................................8 Implicit Global Variables ................................................................................................................8 Explicit Global Variables ................................................................................................................9 Static Global Variables..................................................................................................................11 Using the StoreData() function to generate data records...................................................................11 The StartRun() and EndRun() Functions...........................................................................................12 DTL Language Reference .....................................................................................................................15 Expressions........................................................................................................................................15 Numeric constants .........................................................................................................................15 String constants .............................................................................................................................16 Variable names..............................................................................................................................17 Statement labels.............................................................................................................................17 Operators .......................................................................................................................................18 Comments......................................................................................................................................23 Declarations...........................................................................................................................................25 Variable types....................................................................................................................................25 Variable classes .................................................................................................................................26 Variable declaration statement ..........................................................................................................27 Array declarations .........................................................................................................................28 Variable initialization ....................................................................................................................28 Declaration examples ....................................................................................................................30 Program Statements...............................................................................................................................31 Basic Statement Syntax .....................................................................................................................31 Reserved Keywords...........................................................................................................................31 Assignment Statement.......................................................................................................................32 IF Statement ......................................................................................................................................32 WHILE Statement .............................................................................................................................33 DO Statement ....................................................................................................................................34 LOOP Statement................................................................................................................................35 FOR Statement ..................................................................................................................................35 BREAK Statement ............................................................................................................................36 CONTINUE Statement......................................................................................................................37 GOTO Statement...............................................................................................................................37 RETURN Statement ..........................................................................................................................38 Functions ...............................................................................................................................................41 Declaring Functions ..........................................................................................................................42 Array parameters ...........................................................................................................................43 Function Prototypes...........................................................................................................................45 Invoking Functions............................................................................................................................46 Built-In Library Functions.....................................................................................................................47 Function Error Status.........................................................................................................................47 String Functions ....................................................................................................................................49 strcmp — String comparison.............................................................................................................49 strlen — Determine length of string..................................................................................................50 space — Create blank filled string ....................................................................................................50 trim — Remove spaces from end of a string.....................................................................................50 cleanspaces — Clean up spaces in string ..........................................................................................51 repeat — Create string with repeated pattern ....................................................................................51 locate — Locate substring in string...................................................................................................51 rlocate — Reverse locate substring in string.....................................................................................52 strcount — Count occurrences of a substring....................................................................................53 strupr — Convert string to upper case...............................................................................................53 strlwr — Convert string to lower case...............................................................................................53 mixcase — Convert string to mixed case ..........................................................................................54 translate — Translate characters in string .........................................................................................54 char — Convert ASCII value to character ........................................................................................55 ichar — Convert character to ASCII value .......................................................................................55 isxxxx — Character type tests............................................................................................................55 insert — Insert one string in another .................................................................................................56 element — Locate substring using delimiters ...................................................................................57 validate — Check validity of characters ...........................................................................................57