Skip to content

Commit bc66e2f

Browse files
committed
Package: bpUTiL, Version: 1.0.0
Package: bpUTiL, Version: 1.0.0 - New macro `%bpUTiL_listNonMissVars()` added. --- - File SHA256: `F*390C7CDF54D37027EE50105C0BB26E5908F17B5000190601091A9B5D74055B66` for this version - Content SHA256: `C*D859AC256B335E49D7BAFE5CAB89A922BB230B505CA80AC06AC83DB05A885477` for this version
1 parent bb57a20 commit bc66e2f

File tree

5 files changed

+927
-20
lines changed

5 files changed

+927
-20
lines changed

README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ The `bpUTiL` package, supported by `basePlus` and `macroArray` packages,
66
provides a set of basic popular utility programs to make daily programming
77
work easier.
88

9-
SHA256 digest for the latest version of `bpUTiL`: F*2513DA82048CB4470624B219012D30B873560A6BD4D1C515E3A462CF0E316445
9+
SHA256 digest for the latest version of `bpUTiL`: F*390C7CDF54D37027EE50105C0BB26E5908F17B5000190601091A9B5D74055B66
1010

1111
[**Documentation for bpUTiL**](./bputil.md "Documentation for bpUTiL")
1212

bputil.md

Lines changed: 162 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -9,17 +9,17 @@
99
### Version information:
1010

1111
- Package: bpUTiL
12-
- Version: 0.1.1
13-
- Generated: 2024-12-05T21:07:10
12+
- Version: 1.0.0
13+
- Generated: 2025-01-20T17:19:10
1414
- Author(s): Bartosz Jablonski ([email protected])
1515
- Maintainer(s): Bartosz Jablonski ([email protected])
1616
- License: MIT
17-
- File SHA256: `F*2513DA82048CB4470624B219012D30B873560A6BD4D1C515E3A462CF0E316445` for this version
18-
- Content SHA256: `C*96ADFF959697C27D1A46BC93B5C8E6C095908ECE0142ADF9F0F42266A47B8236` for this version
17+
- File SHA256: `F*390C7CDF54D37027EE50105C0BB26E5908F17B5000190601091A9B5D74055B66` for this version
18+
- Content SHA256: `C*D859AC256B335E49D7BAFE5CAB89A922BB230B505CA80AC06AC83DB05A885477` for this version
1919

2020
---
2121

22-
# The `bpUTiL` package, version: `0.1.1`;
22+
# The `bpUTiL` package, version: `1.0.0`;
2323

2424
---
2525

@@ -43,7 +43,7 @@ Required SAS Packages:
4343

4444
--------------------------------------------------------------------
4545

46-
*SAS package generated by SAS Package Framework, version `20241129`*
46+
*SAS package generated by SAS Package Framework, version `20241207`*
4747

4848
--------------------------------------------------------------------
4949

@@ -52,15 +52,17 @@ The `bpUTiL` package consists of the following content:
5252

5353
1. [`bputil_int_oneliners` exec ](#bputilintoneliners-exec-1 )
5454
2. [`bputil_int_oneliners` clean ](#bputilintoneliners-clean-2 )
55-
3. [`%bputil_int_1varattrsds1()` macro ](#bputilint1varattrsds1-macro-3 )
56-
4. [`%bputil_int_1varattrsds2()` macro ](#bputilint1varattrsds2-macro-4 )
57-
5. [`%bputil_attributes()` macro ](#bputilattributes-macro-5 )
58-
6. [`%bputil_convertn2c()` macro ](#bputilconvertn2c-macro-6 )
59-
7. [`%bputil_includesasnotebook()` macro ](#bputilincludesasnotebook-macro-7 )
60-
8. [`%bputil_varstoonecasesize()` macro ](#bputilvarstoonecasesize-macro-8 )
55+
3. [`$bputil_listnonmissvars.` format/informat ](#bputillistnonmissvars-formats-3 )
56+
4. [`%bputil_int_1varattrsds1()` macro ](#bputilint1varattrsds1-macro-4 )
57+
5. [`%bputil_int_1varattrsds2()` macro ](#bputilint1varattrsds2-macro-5 )
58+
6. [`%bputil_attributes()` macro ](#bputilattributes-macro-6 )
59+
7. [`%bputil_convertn2c()` macro ](#bputilconvertn2c-macro-7 )
60+
8. [`%bputil_includesasnotebook()` macro ](#bputilincludesasnotebook-macro-8 )
61+
9. [`%bputil_listnonmissvars()` macro ](#bputillistnonmissvars-macro-9 )
62+
10. [`%bputil_varstoonecasesize()` macro ](#bputilvarstoonecasesize-macro-10 )
6163

6264

63-
9. [License note](#license)
65+
11. [License note](#license)
6466

6567
---
6668

@@ -84,23 +86,33 @@ Cleaning internal "one-liners" built with BasePlus `%GenerateOneLiners()` macro.
8486

8587
---
8688

87-
## `%bputil_int_1varattrsds1()` macro <a name="bputilint1varattrsds1-macro-3"></a> ######
89+
## `$bputil_listnonmissvars.` format/informat <a name="bputillistnonmissvars-formats-3"></a> ######
90+
Both formats are internal for use of `%bpUTiL_listNonMissVars()` macro.
91+
92+
Both display missing value as a blank space (`" "`) and any
93+
non-missing value as asterisk (`"*"`).
94+
95+
---
96+
97+
---
98+
99+
## `%bputil_int_1varattrsds1()` macro <a name="bputilint1varattrsds1-macro-4"></a> ######
88100
An internal macro to extract attributes information about `i`-th variable
89101
from an `open()` data set with identifier `dsid`.
90102

91103
Dedicated for `DATA STEP` format.
92104

93105
---
94106

95-
## `%bputil_int_1varattrsds2()` macro <a name="bputilint1varattrsds2-macro-4"></a> ######
107+
## `%bputil_int_1varattrsds2()` macro <a name="bputilint1varattrsds2-macro-5"></a> ######
96108
An internal macro to extract attributes information about `i`-th variable
97109
from an `open()` data set with identifier `dsid`.
98110

99111
Dedicated for `PROC DS2` format.
100112

101113
---
102114

103-
## `%bputil_attributes()` macro <a name="bputilattributes-macro-5"></a> ######
115+
## `%bputil_attributes()` macro <a name="bputilattributes-macro-6"></a> ######
104116

105117
### DESCRIPTION: ##############################################################
106118

@@ -249,7 +261,7 @@ quit;
249261

250262
---
251263

252-
## `%bputil_convertn2c()` macro <a name="bputilconvertn2c-macro-6"></a> ######
264+
## `%bputil_convertn2c()` macro <a name="bputilconvertn2c-macro-7"></a> ######
253265

254266
### DESCRIPTION: ##############################################################
255267

@@ -389,7 +401,7 @@ run;
389401

390402
---
391403

392-
## `%bputil_includesasnotebook()` macro <a name="bputilincludesasnotebook-macro-7"></a> ######
404+
## `%bputil_includesasnotebook()` macro <a name="bputilincludesasnotebook-macro-8"></a> ######
393405

394406
### DESCRIPTION: ##############################################################
395407

@@ -495,7 +507,138 @@ The basic syntax is the following, the `<...>` means optional parameters:
495507

496508
---
497509

498-
## `%bputil_varstoonecasesize()` macro <a name="bputilvarstoonecasesize-macro-8"></a> ######
510+
## `%bputil_listnonmissvars()` macro <a name="bputillistnonmissvars-macro-9"></a> ######
511+
512+
### DESCRIPTION: ##############################################################
513+
514+
The `bpUTiL_listNonMissVars()` macro allow for automatic listing of
515+
variables that have at least one non-missing value.
516+
517+
Macro behaves in two possible ways:
518+
1) result can be stored a SAS data set (parameter `out=`), or
519+
2) macro prints a list of values in a "function-like" style (parameter `list=`).
520+
521+
Behaviors are exclusive, i.e., you can select only 1) or 2) for a single
522+
macro call.
523+
524+
Idea for the macro was inspired by SAS communities post:
525+
https://communities.sas.com/t5/SAS-Programming/How-to-find-out-if-all-the-values-of-a-variable-numeric-or/m-p/931919#M366632
526+
527+
Macro executes as pure macro code.
528+
529+
### SYNTAX: ###################################################################
530+
531+
The basic syntax is the following, the `<...>` means optional parameters:
532+
~~~~~~~~~~~~~~~~~~~~~~~sas
533+
%bpUTiL_listNonMissVars(
534+
ds
535+
<,out=>
536+
<,print=>
537+
<,list=>
538+
<,putlog=>
539+
)
540+
~~~~~~~~~~~~~~~~~~~~~~~
541+
542+
**Arguments description**:
543+
544+
1. `ds` - *Required.* Valid data set name.
545+
No data set options can be used.
546+
547+
* `out=` - *Optional.* Name of a data sets to store
548+
produced list of variables.
549+
Default value is: `WORK.anyNonMissingData`.
550+
When `print=` or `list=` are used the data
551+
set is not created.
552+
553+
554+
* `print=` - *Optional.* Indicates if the list of variables
555+
should be stored as a SAS data set (`print=0`) or
556+
the list should be return in "function-like"
557+
style (`print=1`).
558+
`Print=` is an alias to `list=`.
559+
Default value is `0`
560+
561+
* `list=` - *Optional.* Indicates the if list of variables
562+
should be stored as a SAS data set (`list=0`) or
563+
the list should be return in "function-like"
564+
style (`list=1`).
565+
`List=` is an alias to `print=`.
566+
Default value is `0`
567+
568+
* `putlog=` - *Optional.* Indicates if the list of variables
569+
should also displayed in the SAS LOG.
570+
Default value is `0` and means "do not print".
571+
572+
---
573+
574+
575+
### EXAMPLES AND USECASES: ####################################################
576+
577+
**EXAMPLE 1.** Basic use case:
578+
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~sas
579+
%let size=20;
580+
data have haveN(keep=_numeric_) haveC(keep=_character_);
581+
ffffffffffffffffffffffffffffffff = "F";
582+
gggggggggggggggggggggggggggggggg = 123;
583+
array MissC[&size.] $1 ;
584+
array noMissC[&size.] $1 (&size.*"A");
585+
array MissN[&size.] ;
586+
array noMissN[&size.] (&size.* 1 );
587+
do i = 1 to 5e5;
588+
output;
589+
end;
590+
drop i;
591+
run;
592+
593+
%bpUTiL_listNonMissVars(have,putlog=1)
594+
proc print data = anyNonMissingData;
595+
run;
596+
597+
%bpUTiL_listNonMissVars(haveN)
598+
proc print data = anyNonMissingData;
599+
run;
600+
601+
%bpUTiL_listNonMissVars(haveC)
602+
proc print data = anyNonMissingData;
603+
run;
604+
%put %bpUTiL_listNonMissVars(haveC,print=1);
605+
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
606+
607+
**EXAMPLE 2.** Use macro to exclude empty variables:
608+
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~sas
609+
data have1;
610+
infile cards dlm="|" dsd;
611+
input a $ b $ c d e $ f;
612+
cards;
613+
a||.|1|a|1
614+
b||.|2| |.
615+
c||.|3|c|3
616+
d||.|4| |.
617+
run;
618+
619+
proc print data = have1;
620+
run;
621+
622+
%bpUTiL_listNonMissVars(have1,out=WORK.anyNonMissingData1)
623+
proc print data = anyNonMissingData1;
624+
run;
625+
626+
%put %bpUTiL_listNonMissVars(have1,list=1,putlog=1);
627+
628+
data want1;
629+
set have1(keep = %bpUTiL_listNonMissVars(have1,list=1));
630+
run;
631+
632+
proc print data = want1;
633+
run;
634+
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
635+
636+
---
637+
638+
639+
---
640+
641+
## `%bputil_varstoonecasesize()` macro <a name="bputilvarstoonecasesize-macro-10"></a> ######
499642

500643
### DESCRIPTION: ##############################################################
501644

bputil.zip

4.33 KB
Binary file not shown.

0 commit comments

Comments
 (0)