×
INTELLIGENT WORK FORUMS
FOR COMPUTER PROFESSIONALS

Are you a
Computer / IT professional?
Join Tek-Tips Forums!
• Talk With Other Members
• Be Notified Of Responses
• Keyword Search
Favorite Forums
• Automated Signatures
• Best Of All, It's Free!

*Tek-Tips's functionality depends on members receiving e-mail. By joining you are opting in to receive e-mail.

#### Posting Guidelines

Promoting, selling, recruiting, coursework and thesis posting is forbidden.

# SAS Multi-dimension Array

 Forum Search FAQs Links MVPs

## SAS Multi-dimension Array

(OP)
This might be a little challenging ...

1) I need to load a 4 x 3 (row x column) m-array in an array. --- Is this doable?

2) If the data are points on a plane, I need to calculate distance between any two point of the plane. For example:

A  1  2
B  3  4
C  5  6
D  7  8

I Need to calc distance between: A-B, A-C, A-D, B-C, B-D, C-D. Is there a good way to do it in SAS?

Thank you so much ...

### RE: SAS Multi-dimension Array

I would do this one way --- others would do it another (probably the PLI / C background - sorry) -- you could do things like variably determine the size of the array, but this should get you a start;

Data Points;
INFILE *youdefinethis*;
Retain ArrayElem;
ARRAY PointName{10};             <== DEFINE SIZE OF ARRAY
ARRAY PointXCoord(10);
Array PointYCoord(10);
INPUT @1  Point     \$CHAR1.
@3  PointX,
@5  PointY ;
If _n_ =1 /* first record */
Then ArrayElem = 0;
ArrayElem = ArrayElem + 1;
PointName{ArrayElem} = Point;
PointXCoord{ArrayElem} = PointX;
PointYCoord{ArrayElem} = PointY;

Data Distance;
Set Points;
ARRAY PointName{10};
ARRAY PointXCoord(10);
Array PointYCoord(10);

Do I = 1 to Dim(PointName);
Do J = I+1 to Dim(PointName);
From = 'From' || PointName{I} || ' To ' || PointName{J};
Distance = PointXCoord{I}... /*insert desirect formula here */
Keep From Distance;
Output;
End;
End;

My plane geometry is a bit rusty so you will need to do the math, but this should give you an output file with two variables (the label & the distance).

Make sense?

#### Red Flag This Post

Please let us know here why this post is inappropriate. Reasons such as off-topic, duplicates, flames, illegal, vulgar, or students posting their homework.

#### Red Flag Submitted

Thank you for helping keep Tek-Tips Forums free from inappropriate posts.
The Tek-Tips staff will check this out and take appropriate action.

#### Posting in the Tek-Tips forums is a member-only feature.

Click Here to join Tek-Tips and talk with other members! Already a Member? Login

Close Box

# Join Tek-Tips® Today!

Join your peers on the Internet's largest technical computer professional community.
It's easy to join and it's free.

Here's Why Members Love Tek-Tips Forums:

• Talk To Other Members
• Notification Of Responses To Questions
• Favorite Forums One Click Access
• Keyword Search Of All Posts, And More...

Register now while it's still free!