|
1 |
| -SAS_ListProcessing |
2 |
| -================== |
3 |
| -/*=================================================================================== |
4 |
| - | SAS List Processing Utility Macros |
5 |
| - | |
6 |
| - | Author: see individual snippets |
7 |
| - | Collector: Jiangtang Hu (Jiangtanghu.com) |
8 |
| - | Archived: https://github.com/Jiangtang/Programming-SAS/tree/master/ListProcessing |
9 |
| - | |
10 |
| - +-------List Creating--------------------------------------------------------------- |
11 |
| - | |
12 |
| - | %range: produces a sequence like 1 2 3 or f1 f2 f3 or 1a 2a 3a |
13 |
| - | %range_non_int: increment a macro do loop by a non-integer value |
14 |
| - | %suffix_counter: Create a list of variable names formed by adding a numeric counter suffix to a base name. |
15 |
| - | |
16 |
| - | %getVar: get all variables (N, C or all) from a dataset |
17 |
| - | |
18 |
| - | %qreadpipe: read the output of a system command |
19 |
| - | %dir: return a list of members of a directory |
20 |
| - | %dirfpq: return a list of full-path quoted members of a directory |
21 |
| - | |
22 |
| - | |
23 |
| - +-------List Formating--------------------------------------------------------------- |
24 |
| - | |
25 |
| - | %changesep: change the separator for a list |
26 |
| - | %seplist: Emit a list of items separated by some delimiter |
27 |
| - | |
28 |
| - | %splitmac: insert split characters in a macro string |
29 |
| - | |
30 |
| - | %capmac: capitalise the first letter of each word in a macro string |
31 |
| - | |
32 |
| - +-------quoting--------------------------------------------------------------- |
33 |
| - | |
34 |
| - | %qt: add quotes to each element in a list |
35 |
| - | %quotelst: quote the elements of a list |
36 |
| - | |
37 |
| - | %upt: remove quotes from each element of a list |
38 |
| - | %qdequote: remove front and end matching quotes from a macro string |
39 |
| - | %dequote: remove front and end matching quotes from a macro string |
40 |
| - | |
41 |
| - | %noquotes: remove all quoted strings from a macro expression |
42 |
| - | |
43 |
| - | %quotecnt: count quoted strings in a macro expression |
44 |
| - | |
45 |
| - | %quotescan: scan for a quoted string in a macro expression |
46 |
| - | |
47 |
| - | |
48 |
| - +-------List Properties----------------------------------------------------------- |
49 |
| - | |
50 |
| - | %num_tokens: Count the number of “tokens” (variables) in a list. |
51 |
| - | %countW: Retrieve the number of words in a macro variable |
52 |
| - | %words: return the number of words in a string |
53 |
| - | %windex: return the word count position in a string |
54 |
| - | |
55 |
| - | |
56 |
| - | |
57 |
| - | |
58 |
| - +-------List Manipulation----------------------------------------------------------- |
59 |
| - | |
60 |
| - | %slice: return a sub-list sliced by a index |
61 |
| - | |
62 |
| - | |
63 |
| - | %zip: zips two lists together by joining correponding elements, see, a b and c d ==> ac bd |
64 |
| - | %parallel_join: Join two variable lists by connecting each variable in the first list to its correspondingvariable in the second list |
65 |
| - | %add_string: Add a text string to each variable in a list as either a prefix or suffix |
66 |
| - | %xprod: take cross product of two lists, see, a b and c d ==> ac ad bc bd |
67 |
| - | |
68 |
| - | %appmvar: append a string onto an existing macro variable |
69 |
| - | %prefix: return a list with a prefix added |
70 |
| - | %suffix: return a list with a suffix added |
71 |
| - | |
72 |
| - | |
73 |
| - | |
74 |
| - | |
75 |
| - | %replace: replace symbolic variable in block of code with each element of a list, see, a b and code = #=__# ==> a=__a b=__b |
76 |
| - | %rename_string: Create a list suitable for the rename statement |
77 |
| - | %editlist: edit a list of space delimited items |
78 |
| - | |
79 |
| - | %nodup: drop duplicates in a space-delimited list |
80 |
| - | |
81 |
| - | %match: return elements of a list that match those in a reference list |
82 |
| - | |
83 |
| - | %remove: remove all occurrences of the target string(s) from another string |
84 |
| - | %removew: remove all occurrences of the target word(s) from a source list of words. |
85 |
| - | |
86 |
| - | %reverse: Reverse a macro variable's value (use %sysfunc(reverse) since v6.12) |
87 |
| - | |
88 |
| - | |
89 |
| - | |
90 |
| - +==================================================================================*/ |
| 1 | +ho# SAS List Processing Utility Macros |
| 2 | + |
| 3 | +##### Author: see individual macros |
| 4 | +##### Collector: Jiangtang Hu ([www.Jiangtanghu.com](http://www.Jiangtanghu.com)) |
| 5 | +##### Archived: https://github.com/Jiangtang/Programming-SAS/tree/master/ListProcessing |
| 6 | + |
| 7 | +## List Creating |
| 8 | + |
| 9 | +* %range: produces a sequence like 1 2 3 or f1 f2 f3 or 1a 2a 3a |
| 10 | +* %range\_non\_int: increment a macro do loop by a non-integer value |
| 11 | +* %suffix_counter: Create a list of variable names formed by adding a numeric counter suffix to a base name. |
| 12 | + |
| 13 | +* %getVar: get all variables (N, C or all) from a dataset |
| 14 | + |
| 15 | +* %qreadpipe: read the output of a system command |
| 16 | +* %dir: return a list of members of a directory |
| 17 | +* %dirfpq: return a list of full-path quoted members of a directory |
| 18 | + |
| 19 | +## List Formating |
| 20 | + |
| 21 | +* %changesep: change the separator for a list |
| 22 | +* %seplist: Emit a list of items separated by some delimiter |
| 23 | + |
| 24 | +* %splitmac: insert split characters in a macro string |
| 25 | + |
| 26 | +* %capmac: capitalise the first letter of each word in a macro string |
| 27 | + |
| 28 | +## quoting |
| 29 | + |
| 30 | +* %qt: add quotes to each element in a list |
| 31 | +* %quotelst: quote the elements of a list |
| 32 | + |
| 33 | +* %upt: remove quotes from each element of a list |
| 34 | +* %qdequote: remove front and end matching quotes from a macro string |
| 35 | +* %dequote: remove front and end matching quotes from a macro string |
| 36 | + |
| 37 | +* %noquotes: remove all quoted strings from a macro expression |
| 38 | + |
| 39 | +* %quotecnt: count quoted strings in a macro expression |
| 40 | + |
| 41 | +* %quotescan: scan for a quoted string in a macro expression |
| 42 | + |
| 43 | +## List Properties |
| 44 | + |
| 45 | +* %num_tokens: Count the number of “tokens” (variables) in a list. |
| 46 | +* %countW: Retrieve the number of words in a macro variable |
| 47 | +* %words: return the number of words in a string |
| 48 | +* %windex: return the word count position in a string |
| 49 | + |
| 50 | + |
| 51 | +##List Manipulation |
| 52 | + |
| 53 | +* %slice: return a sub-list sliced by a index |
| 54 | + |
| 55 | +* %zip: zips two lists together by joining correponding elements, see, a b and c d ==> ac bd |
| 56 | +* %parallel_join: Join two variable lists by connecting each variable in the first list to its correspondingvariable in the second list |
| 57 | +* %add_string: Add a text string to each variable in a list as either a prefix or suffix |
| 58 | +* %xprod: take cross product of two lists, see, a b and c d ==> ac ad bc bd |
| 59 | + |
| 60 | +* %appmvar: append a string onto an existing macro variable |
| 61 | +* %prefix: return a list with a prefix added |
| 62 | +* %suffix: return a list with a suffix added |
| 63 | + |
| 64 | +* %replace: replace symbolic variable in block of code with each element of a list, see, a b and code = #=__# ==> a=__a b=__b |
| 65 | +* %rename_string: Create a list suitable for the rename statement |
| 66 | +* %editlist: edit a list of space delimited items |
| 67 | + |
| 68 | +* %nodup: drop duplicates in a space-delimited list |
| 69 | + |
| 70 | +* %match: return elements of a list that match those in a reference list |
| 71 | + |
| 72 | +* %remove: remove all occurrences of the target string(s) from another string |
| 73 | +* %removew: remove all occurrences of the target word(s) from a source list of words. |
| 74 | + |
| 75 | +* %reverse: Reverse a macro variable's value (use %sysfunc(reverse) since v6.12) |
| 76 | + |
0 commit comments