Hi,
I'm new to JMP/JSL but have experience with Java and am currently writing a program that needs to iterate through a column of address data and check if the address is already in the system; if it is, it should populate new columns with the latitude and longitude values. I'm using associative arrays and this is what I have so far:
NamesDefaultToHere(1); //all variables local
rawData = Open("Kevin-PriceAnalysis-DO Basis US thru April.jmp");
Current Data Table(rawData); //current data table set to list of hospitals
address = Column(rawData, "Full Address");
dt_latMap = Associative Array(address, rawData:Latitude); //maps unique full address to latitude
dt_longMap = Associative Array(address, rawData:Longitude); //maps unique full address to longitude
dt_coord = new Table("Coordinates",
New Column("Lat", Numeric, Continuous, Format("Lat DDD", 24, 14)),
New Column("Long", Numeric, Continuous, Format("Long DDD", 24, 14))
); //new data table of coordinates (empty)
For(i = 1, i <= N Rows(rawData), i++, //iterates through raw data, checks if contaied in map
If(Contains(dt_latMap, address[i]), //if yes updates coordinates
dt_coord:Lat = dt_latMap<<Get Value(address[i]);
dt_coord:Long = dt_longMap<<Get Value(address[i]),
!Contains(dt_latMap, address[i]), //if not, keep looping
continue();
);
);
I keep getting an "cannot set value for 'Lat' because row number (-1) is invalid. I thought it could be a problem with column naming but I tried changing the names of the columns. Any help would be greatly appreciated! Thanks!