BookmarkSubscribeRSS Feed
🔒 This topic is solved and locked. Need further help from the community? Please sign in and ask a new question.
r_behata
Barite | Level 11

I have come across an array statement which looks like this. 

array credlimchg [1:3,0:1,1:2]

The first dimension corresponds to the rows and the second one to columns, but I am an unable to wrap my head around how to visualize the third one.

 


set test;
Set test; array credlimchg [1:3,0:1,1:2] acs_dec_amt acs_dec_cnt acs_inc_amt acs_inc_cnt man_dec_amt man_dec_cnt man_inc_amt man_inc_cnt oth_dec_amt oth_dec_cnt oth_inc_amt oth_inc_cnt; do x=lbound(credlimchg,1) to hbound(credlimchg,1); do y=lbound(credlimchg,2) to hbound(credlimchg,2); do z=lbound(credlimchg,3) to hbound(credlimchg,3); credlimchg[x,y,z]=0; end; end; end; .............. run;

Any help is greatly appreciated.

1 ACCEPTED SOLUTION

Accepted Solutions
Tom
Super User Tom
Super User

Think of it as groups of tables, like what you get from PROC FREQ when you use a tables statement with three variables.

 

BLOCK =1 

      COL    1  2  3
  row   1    a  b  c
  row   2    d  e  f

BLOCK =2

      COL    1  2  3
  row   1    g  h  i
  row   2    j  k  l 
  

View solution in original post

7 REPLIES 7
PaigeMiller
Diamond | Level 26

but I am an unable to wrap my head around how to visualize the third one.

 

I'm not sure what you mean by "visualize" here.

--
Paige Miller
r_behata
Barite | Level 11

Had the array been defined like :

 

array credlimchg [1:3,0:1] COL1 COL2 COL3;

 

I would have imagined an array like :

 

COL1

COL2

COL3

 

I am unable to place the Third parameter in this picture ( Not sure if it can be Technically classified as a Dimension).

 

Tom
Super User Tom
Super User

Think of it as groups of tables, like what you get from PROC FREQ when you use a tables statement with three variables.

 

BLOCK =1 

      COL    1  2  3
  row   1    a  b  c
  row   2    d  e  f

BLOCK =2

      COL    1  2  3
  row   1    g  h  i
  row   2    j  k  l 
  
Kurt_Bremser
Super User

Picture yourself viewing a city block from straight above. The first dimension would be the East-West road, the second the North-South, and the third the floors in the building.

s_lassen
Meteorite | Level 14

As long as you only have 3 dimensions, you should still be able to visualize it: Imagine a box with two layers: the topmost layer is matrix of values, and the layer below as well. Like you have it in an Excel workbook, where you refer to a cell by row, column and sheet name (or "number", if your sheets are just name "sheet1", "sheet2" etc.).

 

With more dimensions, it becomes difficult. A fourth dimension could be time, so you would then have a series of boxes, one for each day (or year, or hour, or whatever).

 

Then it gets even harder. Not only in terms of visualization, but also in practical application: If you have a 3 by 4 by 4 by 12 by 12 manifold ("manifold", I think, is the mathematician's name for multidimensional matrices), and you know that one of the dimensions is "month", how do you find out exactly which dimension it is (there are two dimensions of size 12!). I had a lot of problems in my younger days, trying to figure out exactly such a problem. Not in SAS, but in APL, which is an all-matrix language. I later spoke to someone working a SimCorp, which make a lot of their calculations using that very powerful language. His comment: "we generally consider it bad programming practice to use more than two dimensions in a matrix".

 

So, generally: avoid making arrays with too many dimensions. Instead use a standard table outlay, with one value (fact) for each combination of dimensions - this is both the normalized database outlay, and the dimensional modelling (Kimball) way of doing it. And SAS has a lot of wonderful procedures (e.g. SUMMARY, SQL, FREQ, you name it) for dealing with that kind of data.

ballardw
Super User

My "go to" for multi-dimensional processing is sort of an "aisle", "cabinet", "drawer" if I need 3. 4 dimenstions adds something like "Room" , then "building, then "block" ...

 

And this gives you a hint to one approach of  the normalizing that @s_lassen mentions. Have variables Aisle, Cabinet, Drawer, each with the values of the dimension range used in the array. Then the array processing of some types move to Proc Summary or such easily.

 

Real rusty with Proc IML but that would be the main place to keep using such arrays, maybe.

 

I remember a comment from the Linear Algebra class I took where the instructor told us an anecdote of attending a presentation that had some portion addressing a 9 dimension space. One of the audience had asked "Can you show this something I can visualize like in 5-space?"

r_behata
Barite | Level 11

@ballardw  @s_lassen  @Tom  @Kurt_Bremser 


Thank you all for your inputs.It would have been difficult to figure this out on my own. 


Turns out that this is a fancy way of driving two sets of metrics "Line Changes and Counts" at one go (or going by the analogy perhaps I should call this as :Block)

3 types of Requests: " Automatic , Manual , Other"  : Building

0 or 1 Sub-Types : Line Increase / Decrease : Room

 

 

 

 

SAS Innovate 2025: Call for Content

Are you ready for the spotlight? We're accepting content ideas for SAS Innovate 2025 to be held May 6-9 in Orlando, FL. The call is open until September 25. Read more here about why you should contribute and what is in it for you!

Submit your idea!

How to Concatenate Values

Learn how use the CAT functions in SAS to join values from multiple variables into a single value.

Find more tutorials on the SAS Users YouTube channel.

Click image to register for webinarClick image to register for webinar

Classroom Training Available!

Select SAS Training centers are offering in-person courses. View upcoming courses for:

View all other training opportunities.

Discussion stats
  • 7 replies
  • 723 views
  • 11 likes
  • 6 in conversation