SLIDE 1
Introducing the COLON Graham Stott Tip: Introducing the COLON - - PowerPoint PPT Presentation
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
SLIDE 2
SLIDE 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 …
SLIDE 4
String Comparisons
- Using hardcoding or complex functions to parse strings?
- Use the colon as a wildcard indicator when comparing instead
- The colon can follow all operators (=:, >=:,<=:, ne:, gt:, lt:, in:). The following 'in:'
- peration will select any string starting with A1, B2 or G5
If mytext in (’HL224’,’HL533’,’HL333’) then do; If substr(mytext,1,2) = ’HL’ then do; If mytext=:’HL’ then do; if mytext in:(’A1’,’B2’,’G5’) then do;
SLIDE 5
A Wildcard Indicator
- When listing variables in drop and keep statements
- Use the colon to enable the use of a prefix to reference multiple variables
Data mydset (drop=A3 A4 A7 A8 A10-A16 B1 C4 C6 D4); Data mydset (drop=A: B: C: D4); Data newData(keep=A1:); Total=sum(of month:);
SLIDE 6
Dynamic Macro Variables
- An alternative to call symput, creating macro variables via proc SQL
- More than one variable? No problem
- A list of values?