introducing the colon
play

Introducing the COLON Graham Stott Tip: Introducing the COLON - PowerPoint PPT Presentation

Introducing the COLON Graham Stott Tip: Introducing the COLON Graham Stott Independent SAS Consultant 0432786140 | Graham@gstott.com Tip: Introducing the COLON SAS uses the colon : in many places Key ones are: When reading input files


  1. Introducing the COLON Graham Stott

  2. Tip: Introducing the COLON Graham Stott Independent SAS Consultant 0432786140 | Graham@gstott.com

  3. Tip: Introducing the COLON SAS uses the colon : in many places Key ones are:  When reading input files (the format modifier)  Used in SQL to assign values to macro variables  In arrays to define the amount of array items needed  As a wildcard indicator  A label  Text searching ... And quite a few more …

  4. String Comparisons  Using hardcoding or complex functions to parse strings? If mytext in (’HL224’,’HL533’,’HL333’) then do; If substr (mytext,1,2) = ’HL’ then do;  Use the colon as a wildcard indicator when comparing instead If mytext =:’HL’ then do;  The colon can follow all operators (=:, >=:,<=:, ne:, gt:, lt:, in:). The following 'in:' operation will select any string starting with A1, B2 or G5 if mytext in:(’A1’,’B2’,’G5’) then do;

  5. A Wildcard Indicator  When listing variables in drop and keep statements Data mydset (drop=A3 A4 A7 A8 A10-A16 B1 C4 C6 D4);  Use the colon to enable the use of a prefix to reference multiple variables Data mydset (drop=A: B: C: D4); Data newData(keep=A1:); Total=sum(of month:);

  6. Dynamic Macro Variables  An alternative to call symput, creating macro variables via proc SQL Proc SQL noprint; Select MaxVal format=12.0 into :MaxVal from myLib.myData; Quit;  More than one variable? No problem Select Value1, Value2 into :Val1, :Val2 from myLib.myData;  A list of values? Select products into :prodList separated by "," from myLib.myData;

Recommend


More recommend