Skip to content

A simple FCMP-based check-in/check-out storage system using dictionary objects in SAS. Store and retrieve data by key, like a digital cloakroom.

License

MIT, MIT licenses found

Licenses found

MIT
LICENSE
MIT
license.sas
Notifications You must be signed in to change notification settings

Morioka-Yutaka/cloak

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

22 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

cloak

A simple FCMP-based check-in/check-out storage system using dictionary objects in SAS. Store and retrieve data by key, like a digital cloakroom.

Image

:cloak_num() Function

Description:
This function simulates a check-in/check-out mechanism for numeric items
using a dictionary (hash-like structure). It accepts a unique tag (character string) and a numeric item for check-in. If an item with the same tag already exists, it rejects the new entry. If the second argument is missing, the function attempts to check out the item associated with the tag.

Inputs: cloak_num(tag_sign,backage)

  tag_sign - A character string used as a key (up to 1000 characters).
  backage  - A numeric value to be stored (for check-in), or missing (for check-out).

Outputs:

  - If check-in: returns a numeric return code (0 for success, 9999 for failure).
  - If check-out: returns the stored numeric value, or 9999 if the tag was not found.

Usage:

data test;
do i = 1 to 10;
 ID = char("ABCDEFGHIJ",i);
 VAR1 =i ;
 VAR2 =cats(ID,VAR1);
 output;
end;
drop i;
run;

data test_output;
 set test end=eof;
 rc1 = cloak_num(ID,Var1);
 rc2 = cloak_char(ID,Var2);

if _N_ in (5,6) then do;
  out1 = cloak_num("B",.);
  out2 = cloak_char("C","");
end;

if eof then do;
  out1 = cloak_num("A",.);
  out2 = cloak_char("A","");
end;

drop rc:;
run;
Image

The value checked in with the A tag in the first line is checked out in the last line.
The value checked in with the B tag in the second line is checked out in the fifth line, so it is clear that it no longer exists in the sixth line.

Notes:

  • This function uses a persistent dictionary to retain values across calls.
  • It logs success or failure messages via the PUT statement.

:cloak_char() Function

Description: This function simulates a check-in/check-out mechanism for character items using a dictionary (hash-like structure). It accepts a unique tag (character string) and a character value for check-in. If an item with the same tag already exists, it rejects the new entry. If the second argument is missing, the function attempts to check out the item associated with the tag.

Inputs: cloak_char(tag_sign,backage)

  tag_sign - A character string used as a key (up to 1000 characters).
  backage  - A character string to be stored (for check-in), or missing (for check-out).
Outputs:
  - If check-in: returns a character string "0" (success) or "9999" (failure).
  - If check-out: returns the stored character value, or "9999" if the tag was not found.

Usage:

data test;
do i = 1 to 10;
 ID = char("ABCDEFGHIJ",i);
 VAR1 =i ;
 VAR2 =cats(ID,VAR1);
 output;
end;
drop i;
run;

data test_output;
 set test end=eof;
 rc1 = cloak_num(ID,Var1);
 rc2 = cloak_char(ID,Var2);

if _N_ in (5,6) then do;
  out1 = cloak_num("B",.);
  out2 = cloak_char("C","");
end;

if eof then do;
  out1 = cloak_num("A",.);
  out2 = cloak_char("A","");
end;

drop rc:;
run;
Image

The value checked in with the A tag in the first line is checked out in the last line.
The value checked in with the C tag in the third line is checked out in the fifth line, so it is clear that it no longer exists in the sixth line.

Notes:

  • This function uses a persistent dictionary to retain values across calls.
  • It logs success or failure messages via the PUT statement.

version history

0.1.0(28July2025): Initial version

What is SAS Packages?

The package is built on top of SAS Packages framework(SPF) developed by Bartosz Jablonski. For more information about SAS Packages framework, see SAS_PACKAGES.
You can also find more SAS Packages(SASPACs) in SASPAC.

How to use SAS Packages? (quick start)

1. Set-up SPF(SAS Packages Framework)

Firstly, create directory for your packages and assign a fileref to it.

filename packages "\path\to\your\packages";

Secondly, enable the SAS Packages Framework.
(If you don't have SAS Packages Framework installed, follow the instruction in SPF documentation to install SAS Packages Framework.)

%include packages(SPFinit.sas)

2. Install SAS package

Install SAS package you want to use using %installPackage() in SPFinit.sas.

%installPackage(packagename, sourcePath=\github\path\for\packagename)

(e.g. %installPackage(ABC, sourcePath=https://github.com/XXXXX/ABC/raw/main/))

3. Load SAS package

Load SAS package you want to use using %loadPackage() in SPFinit.sas.

%loadPackage(packagename)

Enjoy😁

About

A simple FCMP-based check-in/check-out storage system using dictionary objects in SAS. Store and retrieve data by key, like a digital cloakroom.

Topics

Resources

License

MIT, MIT licenses found

Licenses found

MIT
LICENSE
MIT
license.sas

Stars

Watchers

Forks

Packages

No packages published

Languages