Hi,
I wanted to write a SAS code for computing distance given the latitude and longitude of the places....( I got around 1000+ locations and I want to find the distance between each other).
I tried using the single dimension array but it seems to be generating erroneous values.
So resorted to 2D array....someone suggested that I use this logic
START will keep track of which city */
/* is the current "from". Calculate the distance to all */
/* the other "to" cities. */
START=1;
DO I=1 TO 1222;
DO J=1 TO (START-1),(START+1) TO 1222; /*?PLEASE HELP ME UNDERSTAND THIS STATEMENT ??*/
X1=lon (START);
Y1=lat(START);
X2=lon(J);
Y2=lat(J);
DIST(I,J)=4000*ARCOS(SIN(Y2)*SIN(Y1)+COS(Y2)*COS(Y1)*COS(X2-X1) );
/*the formula can be changed as per the requirement and the results observed*/;
END;
Can anyone understand this statement in the above code
DO J=1 TO (START-1),(START+1) TO 1222;
Its a bit weird to visulalise the 2D array in SAS in the above code
cheers
I wanted to write a SAS code for computing distance given the latitude and longitude of the places....( I got around 1000+ locations and I want to find the distance between each other).
I tried using the single dimension array but it seems to be generating erroneous values.
So resorted to 2D array....someone suggested that I use this logic
START will keep track of which city */
/* is the current "from". Calculate the distance to all */
/* the other "to" cities. */
START=1;
DO I=1 TO 1222;
DO J=1 TO (START-1),(START+1) TO 1222; /*?PLEASE HELP ME UNDERSTAND THIS STATEMENT ??*/
X1=lon (START);
Y1=lat(START);
X2=lon(J);
Y2=lat(J);
DIST(I,J)=4000*ARCOS(SIN(Y2)*SIN(Y1)+COS(Y2)*COS(Y1)*COS(X2-X1) );
/*the formula can be changed as per the requirement and the results observed*/;
END;
Can anyone understand this statement in the above code
DO J=1 TO (START-1),(START+1) TO 1222;
Its a bit weird to visulalise the 2D array in SAS in the above code
cheers