Thank you so much to everyone for your solutions!
Yes, I am looking to go from ugly lat/long in degrees minutes seconds to decimal degrees using proc SQL.
I am going to choose Collin as my 'right' answer, as his solution is insensitive to the number of digits over six, and also to the presence/absence of the period separators.
I did find that when I used -1 to scan from the end of the string back for longitude that I needed to multiply the result by 10 for the result to have the right number of decimals. I'm sure that would not be necessary if I understood the prxchange function.
Wendy T.
data have ;
length ZONE_GPS_DMS $25 ;
input ZONE_GPS_DMS 1-25 ;
datalines ;
283667 0813551
N28.36.67 W081.35.51
N283667 W0813551
q28.36678 x081.35514
N28.36.678 W081.35.514
N2836678 W08135514
N28366789 W081355149
N28.36.678 W081.35.5149
N2836678 W081355149
;
run ;
proc sql noprint ;
create table example
as select
ZONE_GPS_DMS,
(input(scan(ZONE_GPS_DMS,1,'NW. '),best.)) + (input(scan(ZONE_GPS_DMS,2,'NW. '),best.))/60 + (input(scan(ZONE_GPS_DMS,3,'NW. '),best.))/3600 as lat_dd_ballard
, (input(scan(ZONE_GPS_DMS,4,'NW. '),best.)) + (input(scan(ZONE_GPS_DMS,5,'NW. '),best.))/60 + (input(scan(ZONE_GPS_DMS,6,'NW. '),best.))/3600 as long_dd_ballard
, input(prxchange('s/(\d{6})(\d{0,})/\1.\2/', 1, scan(compress(ZONE_GPS_DMS,'.'), 1, , "dko")), best.) as collin_lat ,
(int(calculated collin_lat/10000)) + ((int(calculated collin_lat/100) - ((int(calculated collin_lat/10000)) * 100))/60) +
((calculated collin_lat - ((int(calculated collin_lat/10000)) * 10000)-((int(calculated collin_lat/100) -
((int(calculated collin_lat/10000)) *100))*100))/3600)
as LAT_DD_collin label='Latitude (dd)'
, input(prxchange('s/(\d{6})(\d{0,})/\1.\2/', 1, scan(compress(ZONE_GPS_DMS,'.'), -1, , "dko")), best.)*10 as collin_long ,
(int(calculated collin_long/10000)) + ((int(calculated collin_long/100) - ((int(calculated collin_long/10000)) * 100))/60) +
((calculated collin_long - ((int(calculated collin_long/10000)) * 10000)-((int(calculated collin_long/100) -
((int(calculated collin_long/10000)) *100))*100))/3600)
as LONG_DD_collin label='Longitude (dd)'
from have ;
quit ;
... View more