Hi,
I need to convert UTM-X and UTM-Y to Latitude and Longitude in meter for Datum ED50 and Zone 31N:
UTM-X = 513932.02
UTMY = 6266840.53
the answer should be
LAT = 56.54444957
LONG= 3.2265688702
I have used the formula here:
https://communities.sas.com/t5/SAS-Communities-Library/Convert-LAT-LONG-to-UTM-and-back/ta-p/221779
However, in this formula
datum=WGS84
zone = 18N
I can change zone but when I change datum to ED50 I get trouble with proj4.
What is proj4?
How can I change it to be fitted for ED50???
I would be very grateful if you could help me with this
Please provide the exact code that you used and the data set used as data step code. Paste both into a code box opened using the forum's {I} or "running man" icons.
I am not even going to guess how someone actually modified example code, as in the link provided, and then reports an issue.
It may also help to describe the trouble when changing the datum.
PROJ4 is the set of calculations to do the Lat Long conversion to Mercator coordinates.
Hi,
Thank you for your fast reponse. Here is my codes. They are working however, I want them for ED50 and not WGS84:
%macro latLong2UTM(DSN,lat=LAT,long=LONG,zone=18N);
data _null_;
no = compress("&zone", , "as");
if findc("&zone", "sS") = 0 then
call symputx("to", cats("+proj=utm +datum=WGS84 +units=m +no_defs +zone=", no));
else call symputx("to", cats("+proj=utm +datum=WGS84 +units=m +no_defs +south +zone=", no));
run;
proc gproject latlon degrees
project = proj4
from = "+proj=longlat +ellps=WGS84 +datum=WGS84 +no_defs"
to = "&to"
data = &DSN(rename=(&lat=LAT &long=LONG))
out = &DSN;
id;
run;
%mend;
%macro UTM2latLong(DSN,y=Y,x=X,zone=18N);
data _null_;
no = compress("&zone", , "as");
if findc("&zone", "sS") = 0 then
call symputx("from", cats("+proj=utm +datum=WGS84 +units=m +no_defs +zone=", no));
else call symputx("from", cats("+proj=utm +datum=WGS84 +units=m +no_defs +south +zone=", no));
run;
data _UTM2latLong;
set &DSN;
_oldX = &x;
_oldY = &y;
rename &x=X &y=Y;
run;
proc gproject
project = proj4
to = "+proj=longlat +ellps=WGS84 +datum=WGS84 +no_defs"
from = "&from"
data = _UTM2latLong
out = _UTM2latLong;
id;
run;
data &DSN(drop=x y rename=(_oldX=&x _oldY=&y));
set _UTM2latLong;
lat = y;
long = x;
run;
proc sql; drop table _UTM2latLong; quit;
%mend;
data test;
infile datalines delimiter=',';
input lat long ;
datalines;
56.547480166,3.218883593
56.547518793,3.2189358171
56.547515029,3.2189742138
;
title "Original coordinates";
proc print data=test noobs; run;
%LatLong2UTM(test);
title "LatLong2UTM";
proc print data=test noobs; run;
data test2(drop=lat long);
set test;
run;
title "Original UTMs";
proc print data=test2 noobs; run;
%UTM2LatLong(test2);
title "UTM2LatLong";
proc print data=test2 noobs; run;
**************************************** */
data &DSN(drop=x y rename=(_oldX=&x _oldY=&y));
set _UTM2latLong;
lat = y;
long = x;
run;
proc sql; drop table _UTM2latLong; quit;
%mend;
Looking in the SASHELP.PROJ4DEF data set it looks like the Name that you want is the EPSG:4154. The description says that is for ED50(ED77)
or possibly the TO string value of "+proj=longlat +ellps=intl +towgs84=-117,-132,-164,0,0,0,0 +no_defs"
Dear sir,
Thank you very much
Best regards
Farshid
Proj4 is an open source coordinate projection software.
Looks like the proj4 from-string for ED50 UTM zone 31N should be
+proj=utm +zone=31 +ellps=intl +units=m +no_defs
Look here
https://spatialreference.org/ref/?search=ED50
Thank you very much!
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!
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.