×
INTELLIGENT WORK FORUMS
FOR COMPUTER PROFESSIONALS

Contact US

Log In

Come Join Us!

Are you a
Computer / IT professional?
Join Tek-Tips Forums!
  • Talk With Other Members
  • Be Notified Of Responses
    To Your Posts
  • Keyword Search
  • One-Click Access To Your
    Favorite Forums
  • Automated Signatures
    On Your Posts
  • 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.

Students Click Here

SAS Multi-dimension Array

SAS Multi-dimension Array

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.

Reply To This Thread

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:

Register now while it's still free!

Already a member? Close this window and log in.

Join Us             Close