Skip to content

Commit

Permalink
Package: bpUTiL, Version: 1.0.0
Browse files Browse the repository at this point in the history
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
  • Loading branch information
yabwon committed Jan 20, 2025
1 parent bb57a20 commit bc66e2f
Show file tree
Hide file tree
Showing 5 changed files with 927 additions and 20 deletions.
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ The `bpUTiL` package, supported by `basePlus` and `macroArray` packages,
provides a set of basic popular utility programs to make daily programming
work easier.

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

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

Expand Down
181 changes: 162 additions & 19 deletions bputil.md
Original file line number Diff line number Diff line change
Expand Up @@ -9,17 +9,17 @@
### Version information:

- Package: bpUTiL
- Version: 0.1.1
- Generated: 2024-12-05T21:07:10
- Version: 1.0.0
- Generated: 2025-01-20T17:19:10
- Author(s): Bartosz Jablonski (yabwon@gmail.com)
- Maintainer(s): Bartosz Jablonski (yabwon@gmail.com)
- License: MIT
- File SHA256: `F*2513DA82048CB4470624B219012D30B873560A6BD4D1C515E3A462CF0E316445` for this version
- Content SHA256: `C*96ADFF959697C27D1A46BC93B5C8E6C095908ECE0142ADF9F0F42266A47B8236` for this version
- File SHA256: `F*390C7CDF54D37027EE50105C0BB26E5908F17B5000190601091A9B5D74055B66` for this version
- Content SHA256: `C*D859AC256B335E49D7BAFE5CAB89A922BB230B505CA80AC06AC83DB05A885477` for this version

---

# The `bpUTiL` package, version: `0.1.1`;
# The `bpUTiL` package, version: `1.0.0`;

---

Expand All @@ -43,7 +43,7 @@ Required SAS Packages:

--------------------------------------------------------------------

*SAS package generated by SAS Package Framework, version `20241129`*
*SAS package generated by SAS Package Framework, version `20241207`*

--------------------------------------------------------------------

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

1. [`bputil_int_oneliners` exec ](#bputilintoneliners-exec-1 )
2. [`bputil_int_oneliners` clean ](#bputilintoneliners-clean-2 )
3. [`%bputil_int_1varattrsds1()` macro ](#bputilint1varattrsds1-macro-3 )
4. [`%bputil_int_1varattrsds2()` macro ](#bputilint1varattrsds2-macro-4 )
5. [`%bputil_attributes()` macro ](#bputilattributes-macro-5 )
6. [`%bputil_convertn2c()` macro ](#bputilconvertn2c-macro-6 )
7. [`%bputil_includesasnotebook()` macro ](#bputilincludesasnotebook-macro-7 )
8. [`%bputil_varstoonecasesize()` macro ](#bputilvarstoonecasesize-macro-8 )
3. [`$bputil_listnonmissvars.` format/informat ](#bputillistnonmissvars-formats-3 )
4. [`%bputil_int_1varattrsds1()` macro ](#bputilint1varattrsds1-macro-4 )
5. [`%bputil_int_1varattrsds2()` macro ](#bputilint1varattrsds2-macro-5 )
6. [`%bputil_attributes()` macro ](#bputilattributes-macro-6 )
7. [`%bputil_convertn2c()` macro ](#bputilconvertn2c-macro-7 )
8. [`%bputil_includesasnotebook()` macro ](#bputilincludesasnotebook-macro-8 )
9. [`%bputil_listnonmissvars()` macro ](#bputillistnonmissvars-macro-9 )
10. [`%bputil_varstoonecasesize()` macro ](#bputilvarstoonecasesize-macro-10 )


9. [License note](#license)
11. [License note](#license)

---

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

---

## `%bputil_int_1varattrsds1()` macro <a name="bputilint1varattrsds1-macro-3"></a> ######
## `$bputil_listnonmissvars.` format/informat <a name="bputillistnonmissvars-formats-3"></a> ######
Both formats are internal for use of `%bpUTiL_listNonMissVars()` macro.

Both display missing value as a blank space (`" "`) and any
non-missing value as asterisk (`"*"`).

---

---

## `%bputil_int_1varattrsds1()` macro <a name="bputilint1varattrsds1-macro-4"></a> ######
An internal macro to extract attributes information about `i`-th variable
from an `open()` data set with identifier `dsid`.

Dedicated for `DATA STEP` format.

---

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

Dedicated for `PROC DS2` format.

---

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

### DESCRIPTION: ##############################################################

Expand Down Expand Up @@ -249,7 +261,7 @@ quit;

---

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

### DESCRIPTION: ##############################################################

Expand Down Expand Up @@ -389,7 +401,7 @@ run;

---

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

### DESCRIPTION: ##############################################################

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

---

## `%bputil_varstoonecasesize()` macro <a name="bputilvarstoonecasesize-macro-8"></a> ######
## `%bputil_listnonmissvars()` macro <a name="bputillistnonmissvars-macro-9"></a> ######

### DESCRIPTION: ##############################################################

The `bpUTiL_listNonMissVars()` macro allow for automatic listing of
variables that have at least one non-missing value.

Macro behaves in two possible ways:
1) result can be stored a SAS data set (parameter `out=`), or
2) macro prints a list of values in a "function-like" style (parameter `list=`).

Behaviors are exclusive, i.e., you can select only 1) or 2) for a single
macro call.

Idea for the macro was inspired by SAS communities post:
https://communities.sas.com/t5/SAS-Programming/How-to-find-out-if-all-the-values-of-a-variable-numeric-or/m-p/931919#M366632

Macro executes as pure macro code.

### SYNTAX: ###################################################################

The basic syntax is the following, the `<...>` means optional parameters:
~~~~~~~~~~~~~~~~~~~~~~~sas
%bpUTiL_listNonMissVars(
ds
<,out=>
<,print=>
<,list=>
<,putlog=>
)
~~~~~~~~~~~~~~~~~~~~~~~

**Arguments description**:

1. `ds` - *Required.* Valid data set name.
No data set options can be used.

* `out=` - *Optional.* Name of a data sets to store
produced list of variables.
Default value is: `WORK.anyNonMissingData`.
When `print=` or `list=` are used the data
set is not created.


* `print=` - *Optional.* Indicates if the list of variables
should be stored as a SAS data set (`print=0`) or
the list should be return in "function-like"
style (`print=1`).
`Print=` is an alias to `list=`.
Default value is `0`

* `list=` - *Optional.* Indicates the if list of variables
should be stored as a SAS data set (`list=0`) or
the list should be return in "function-like"
style (`list=1`).
`List=` is an alias to `print=`.
Default value is `0`

* `putlog=` - *Optional.* Indicates if the list of variables
should also displayed in the SAS LOG.
Default value is `0` and means "do not print".

---


### EXAMPLES AND USECASES: ####################################################

**EXAMPLE 1.** Basic use case:
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~sas
%let size=20;
data have haveN(keep=_numeric_) haveC(keep=_character_);
ffffffffffffffffffffffffffffffff = "F";
gggggggggggggggggggggggggggggggg = 123;
array MissC[&size.] $1 ;
array noMissC[&size.] $1 (&size.*"A");
array MissN[&size.] ;
array noMissN[&size.] (&size.* 1 );
do i = 1 to 5e5;
output;
end;
drop i;
run;
%bpUTiL_listNonMissVars(have,putlog=1)
proc print data = anyNonMissingData;
run;
%bpUTiL_listNonMissVars(haveN)
proc print data = anyNonMissingData;
run;
%bpUTiL_listNonMissVars(haveC)
proc print data = anyNonMissingData;
run;
%put %bpUTiL_listNonMissVars(haveC,print=1);
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

**EXAMPLE 2.** Use macro to exclude empty variables:
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~sas
data have1;
infile cards dlm="|" dsd;
input a $ b $ c d e $ f;
cards;
a||.|1|a|1
b||.|2| |.
c||.|3|c|3
d||.|4| |.
run;
proc print data = have1;
run;
%bpUTiL_listNonMissVars(have1,out=WORK.anyNonMissingData1)
proc print data = anyNonMissingData1;
run;
%put %bpUTiL_listNonMissVars(have1,list=1,putlog=1);
data want1;
set have1(keep = %bpUTiL_listNonMissVars(have1,list=1));
run;
proc print data = want1;
run;
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

---


---

## `%bputil_varstoonecasesize()` macro <a name="bputilvarstoonecasesize-macro-10"></a> ######

### DESCRIPTION: ##############################################################

Expand Down
Binary file modified bputil.zip
Binary file not shown.
Loading

0 comments on commit bc66e2f

Please sign in to comment.