[prev in list] [next in list] [prev in thread] [next in thread] 

List:       sas-l
Subject:    Macro-Arrays - version 1.0 - what do you think about it?
From:       Mariusz Gromada <mariusz.gromada () WP ! PL>
Date:       2003-08-31 13:18:56
[Download RAW message or body]

Macro-Arrays can be very useful. We can create many of it at the same
time. One array can be used in different macro-programs or data steps.

And what do you think about it?

go to:
http://atraktor.ask33.net/sas/macroarrays.sas

  ------------------------------------------------------
| name      : Macro Arrays                             |
| version   : 1.0                                      |
| author    : Mariusz Gromada                          |
| date      : 31.08.2003                               |
| contact   : mariusz.gromada@wp.pl                    |
  ------------------------------------------------------

You can use:
    - CreateArray
    - PutValue
    - GetValue

sasautos extensions from Roland's page needed
http://www.datasavantconsulting.com/roland/sasautos.html

- match.sas
- globlist.sas
- globexist.sas
- nodup.sas
- words.sas


======================================================================
CreateArray
======================================================================
Creates Macro Array

%CreateArray(n1,n2,...,nk,Name=<,CellSize=><,EOC=>);

n1,n2,...,nk - dimensions (ni>1)
Name - name of the MacroArray
CellSize - size of the one cell (in characters) (default CellSize=12)
EOC - End Of Cell char (default EOC=^)

%CreateArray - creates global macro-variable named &Name (if global
macro-variable named &Name doesn't exists).

To destroy (delete) MacroArray use %symdel ArrayName;

n1*n2*...*nk*CellSize < 32768

examples:
---------------------------------------------------------------------

%CreateArray(10,10,Name=tab);

NOTE: (CreateArray) Starting with (10,10,Name=tab):
NOTE:     Name     = tab
NOTE:     CellSize = 12
NOTE:     EOC      = ^
       --------------------------------------------------

NOTE: (CreateArray) Getting dimensions:
       --------------------------------------------------
NOTE:     n1=10
NOTE:     n2=10
NOTE: (CreateArray) 2 dimensional Macro-Array created! (10,10,NAME=TAB)

%symdel tab;
%CreateArray(2,5,4,6,10,Name=tab,CellSize=8,EOC=@);

NOTE: (CreateArray) Starting with (2,5,4,6,10,Name=tab,CellSize=8,EOC=@):
NOTE:     Name     = tab
NOTE:     CellSize = 8
NOTE:     EOC      = @
       --------------------------------------------------

NOTE: (CreateArray) Getting dimensions:
       --------------------------------------------------
NOTE:     n1=2
NOTE:     n2=5
NOTE:     n3=4
NOTE:     n4=6
NOTE:     n5=10
NOTE: (CreateArray) 5 dimensional Macro-Array created!
(2,5,4,6,10,NAME=TAB,CELLSIZE=8,EOC=@)


======================================================================
PutValu
======================================================================
Puts a value into the MacroArray (if the MacroArray exists)

%PutValue(w1,w2,...,wk,Array=,Value=);

w1,w2,...,wk - co-ordinates ( 1 <= wi < ni )
Array - name of the MacriArray
Value - inserted value

examples:
---------------------------------------------------------------------

%symdel tab;
%CreateArray(10,10,Name=tab,CellSize=8,EOC=@);
%PutValue(2,4,Array=tab,Value=10);

======================================================================
GetValue
======================================================================
Gets a value from the MacroArray

%GetValue(w1,w2,...,wk,Array=)

w1,w2,...,wk - co-ordinates ( 1 <= wi <= ni )
Array - MacroArray name

examples:
---------------------------------------------------------------------

%symdel tab;
%CreateArray(10,10,5,3,Name=tab,CellSize=10,EOC=@);
%PutValue(3,4,2,2,Array=tab,Value=Hello);
%put %GetValue(3,4,2,2,Array=tab);

3791   %symdel tab;
3792   %CreateArray(10,10,5,3,Name=tab,CellSize=10,EOC=@);

NOTE: (CreateArray) Starting with (10,10,5,3,Name=tab,CellSize=10,EOC=@):
NOTE:     Name     = tab
NOTE:     CellSize = 10
NOTE:     EOC      = @
       --------------------------------------------------

NOTE: (CreateArray) Getting dimensions:
       --------------------------------------------------
NOTE:     n1=10
NOTE:     n2=10
NOTE:     n3=5
NOTE:     n4=3
NOTE: (CreateArray) 4 dimensional Macro-Array created!
(10,10,5,3,NAME=TAB,CELLSIZE=10,EOC=@)
3793   %PutValue(3,4,2,2,Array=tab,Value=Hello);

NOTE: (PutValue) Starting with:
NOTE:     Value = Hello
       --------------------------------------------------

3794   %put %GetValue(3,4,2,2,Array=tab);

NOTE: (GetValue) Starting with:
NOTE:     Array = tab
       --------------------------------------------------
Hello

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


Regards,
Mariusz

--
Mariusz Gromada
http://atraktor.ask33.net/

[prev in list] [next in list] [prev in thread] [next in thread] 

Configure | About | News | Add a list | Sponsored by KoreLogic