forked from maquee-sas/SASStudioWorkshop
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathGeoDist with Rounding.step
executable file
·1 lines (1 loc) · 7.12 KB
/
GeoDist with Rounding.step
1
{"creationTimeStamp":"2024-04-01T15:16:44.186Z","modifiedTimeStamp":"2024-04-01T16:18:35.428Z","createdBy":"Alex","modifiedBy":"Alex","name":"GeoDist with Rounding.step","displayName":"GeoDist with Rounding.step","localDisplayName":"GeoDist with Rounding.step","properties":{},"links":[{"method":"GET","rel":"self","href":"/dataFlows/steps/880c37d0-31e7-40f4-a214-e8da4a426ff4","uri":"/dataFlows/steps/880c37d0-31e7-40f4-a214-e8da4a426ff4","type":"application/vnd.sas.data.flow.step"},{"method":"GET","rel":"alternate","href":"/dataFlows/steps/880c37d0-31e7-40f4-a214-e8da4a426ff4","uri":"/dataFlows/steps/880c37d0-31e7-40f4-a214-e8da4a426ff4","type":"application/vnd.sas.data.flow.step.summary"},{"method":"GET","rel":"up","href":"/dataFlows/steps","uri":"/dataFlows/steps","type":"application/vnd.sas.collection","itemType":"application/vnd.sas.data.flow.step.summary"},{"method":"PUT","rel":"update","href":"/dataFlows/steps/880c37d0-31e7-40f4-a214-e8da4a426ff4","uri":"/dataFlows/steps/880c37d0-31e7-40f4-a214-e8da4a426ff4","type":"application/vnd.sas.data.flow.step","responseType":"application/vnd.sas.data.flow.step"},{"method":"DELETE","rel":"delete","href":"/dataFlows/steps/880c37d0-31e7-40f4-a214-e8da4a426ff4","uri":"/dataFlows/steps/880c37d0-31e7-40f4-a214-e8da4a426ff4"},{"method":"GET","rel":"transferExport","href":"/dataFlows/steps/880c37d0-31e7-40f4-a214-e8da4a426ff4","uri":"/dataFlows/steps/880c37d0-31e7-40f4-a214-e8da4a426ff4","responseType":"application/vnd.sas.transfer.object"},{"method":"PUT","rel":"transferImportUpdate","href":"/dataFlows/steps/880c37d0-31e7-40f4-a214-e8da4a426ff4","uri":"/dataFlows/steps/880c37d0-31e7-40f4-a214-e8da4a426ff4","type":"application/vnd.sas.transfer.object","responseType":"application/vnd.sas.summary"}],"metadataVersion":0.0,"version":2,"type":"code","flowMetadata":{"inputPorts":[{"name":"inTable","displayName":"inTable","localDisplayName":"inTable","minEntries":1,"maxEntries":1,"defaultEntries":0,"type":"table"}],"outputPorts":[{"name":"outTable","displayName":"outTable","localDisplayName":"outTable","minEntries":1,"maxEntries":1,"defaultEntries":0,"type":"table","columnDelta":{"updateColumnArguments":["newColumn"],"automaticMapping":[{"inputPort":"inTable","inputPortName":"inTable"}]},"supportsView":false,"requiresStructure":false}]},"ui":"{\n\t\"showPageContentOnly\": true,\n\t\"pages\": [\n\t\t{\n\t\t\t\"id\": \"GeoDist\",\n\t\t\t\"type\": \"page\",\n\t\t\t\"label\": \"Calculate Geo Distance\",\n\t\t\t\"children\": [\n\t\t\t\t{\n\t\t\t\t\t\"id\": \"inTable\",\n\t\t\t\t\t\"type\": \"inputtable\",\n\t\t\t\t\t\"label\": \"Input table\",\n\t\t\t\t\t\"required\": true,\n\t\t\t\t\t\"placeholder\": \"\",\n\t\t\t\t\t\"visible\": \"\"\n\t\t\t\t},\n\t\t\t\t{\n\t\t\t\t\t\"id\": \"disType\",\n\t\t\t\t\t\"type\": \"radiogroup\",\n\t\t\t\t\t\"label\": \"Calculate Distance in:\",\n\t\t\t\t\t\"items\": [\n\t\t\t\t\t\t{\n\t\t\t\t\t\t\t\"value\": \"Kilometers\"\n\t\t\t\t\t\t},\n\t\t\t\t\t\t{\n\t\t\t\t\t\t\t\"value\": \"Miles\"\n\t\t\t\t\t\t}\n\t\t\t\t\t],\n\t\t\t\t\t\"visible\": \"\"\n\t\t\t\t},\n\t\t\t\t{\n\t\t\t\t\t\"id\": \"latlong\",\n\t\t\t\t\t\"type\": \"section\",\n\t\t\t\t\t\"label\": \"Lat/Long Columns\",\n\t\t\t\t\t\"open\": true,\n\t\t\t\t\t\"visible\": \"\",\n\t\t\t\t\t\"children\": [\n\t\t\t\t\t\t{\n\t\t\t\t\t\t\t\"id\": \"loc1\",\n\t\t\t\t\t\t\t\"type\": \"columnselector\",\n\t\t\t\t\t\t\t\"label\": \"Location 1\",\n\t\t\t\t\t\t\t\"order\": false,\n\t\t\t\t\t\t\t\"columntype\": \"n\",\n\t\t\t\t\t\t\t\"max\": 2,\n\t\t\t\t\t\t\t\"min\": 2,\n\t\t\t\t\t\t\t\"visible\": \"\",\n\t\t\t\t\t\t\t\"table\": \"inTable\"\n\t\t\t\t\t\t},\n\t\t\t\t\t\t{\n\t\t\t\t\t\t\t\"id\": \"loc2\",\n\t\t\t\t\t\t\t\"type\": \"columnselector\",\n\t\t\t\t\t\t\t\"label\": \"Location 2\",\n\t\t\t\t\t\t\t\"order\": false,\n\t\t\t\t\t\t\t\"columntype\": \"n\",\n\t\t\t\t\t\t\t\"max\": 2,\n\t\t\t\t\t\t\t\"min\": 2,\n\t\t\t\t\t\t\t\"visible\": \"\",\n\t\t\t\t\t\t\t\"table\": \"inTable\"\n\t\t\t\t\t\t}\n\t\t\t\t\t]\n\t\t\t\t},\n\t\t\t\t{\n\t\t\t\t\t\"id\": \"newColumn\",\n\t\t\t\t\t\"type\": \"newcolumn\",\n\t\t\t\t\t\"label\": \"Distance between the locations\",\n\t\t\t\t\t\"required\": true,\n\t\t\t\t\t\"placeholder\": \"\",\n\t\t\t\t\t\"hideproperties\": false,\n\t\t\t\t\t\"readonly\": false,\n\t\t\t\t\t\"visible\": false\n\t\t\t\t},\n\t\t\t\t{\n\t\t\t\t\t\"id\": \"outTable\",\n\t\t\t\t\t\"type\": \"outputtable\",\n\t\t\t\t\t\"label\": \"Output table\",\n\t\t\t\t\t\"required\": true,\n\t\t\t\t\t\"placeholder\": \"\",\n\t\t\t\t\t\"visible\": \"\"\n\t\t\t\t}\n\t\t\t]\n\t\t},\n\t\t{\n\t\t\t\"id\": \"options\",\n\t\t\t\"label\": \"Options\",\n\t\t\t\"type\": \"page\",\n\t\t\t\"children\": [\n\t\t\t\t{\n\t\t\t\t\t\"id\": \"round\",\n\t\t\t\t\t\"type\": \"checkbox\",\n\t\t\t\t\t\"label\": \"Round Calculated Distance\",\n\t\t\t\t\t\"visible\": \"\"\n\t\t\t\t},\n\t\t\t\t{\n\t\t\t\t\t\"id\": \"decimalPlaces\",\n\t\t\t\t\t\"type\": \"numberfield\",\n\t\t\t\t\t\"label\": \"Enter number of decimal places to round to:\",\n\t\t\t\t\t\"placeholder\": \"\",\n\t\t\t\t\t\"required\": true,\n\t\t\t\t\t\"max\": 5,\n\t\t\t\t\t\"min\": 0,\n\t\t\t\t\t\"excludemin\": false,\n\t\t\t\t\t\"excludemax\": false,\n\t\t\t\t\t\"visible\": \"$round\",\n\t\t\t\t\t\"integer\": true\n\t\t\t\t}\n\t\t\t]\n\t\t},\n\t\t{\n\t\t\t\"id\": \"about\",\n\t\t\t\"label\": \"About\",\n\t\t\t\"type\": \"page\",\n\t\t\t\"children\": [\n\t\t\t\t{\n\t\t\t\t\t\"id\": \"text1\",\n\t\t\t\t\t\"type\": \"text\",\n\t\t\t\t\t\"text\": \"This custom step was built for a workshop. It calculates the distance between two locations.\",\n\t\t\t\t\t\"visible\": \"\"\n\t\t\t\t}\n\t\t\t]\n\t\t}\n\t],\n\t\"syntaxversion\": \"1.3.0\",\n\t\"values\": {\n\t\t\"inTable\": {\n\t\t\t\"library\": \"\",\n\t\t\t\"table\": \"\"\n\t\t},\n\t\t\"disType\": {\n\t\t\t\"value\": \"Miles\"\n\t\t},\n\t\t\"loc1\": [],\n\t\t\"loc2\": [],\n\t\t\"newColumn\": {\n\t\t\t\"value\": \"distance\",\n\t\t\t\"label\": \"distance between locations\",\n\t\t\t\"type\": \"n\",\n\t\t\t\"length\": 8\n\t\t},\n\t\t\"outTable\": {\n\t\t\t\"library\": \"\",\n\t\t\t\"table\": \"\"\n\t\t},\n\t\t\"round\": false,\n\t\t\"decimalPlaces\": 2\n\t}\n}","templates":{"SAS":"/* Set Input and Output Data */\ndata &outTable ;\n set &inTable ;\n\n\n/* newColumn is a hidden control in the UI. The code sets the name of the new output column. */\n\n/* Calculate GeoDistance in Miles */\n%if &disType=Miles %then %do ;\n %let newColumn_name=distance_in_Miles ;\n &newColumn_name=geodist(&loc1_1_name, &loc1_2_name, &loc2_1_name, &loc2_2_name, 'M') ;\n%end;\n\n/* Calculate GeoDistance in Kilometers */\n%else %do ;\n %let newColumn_name=distance_in_Kilometers ;\n &newColumn_name=geodist(&loc1_1_name, &loc1_2_name, &loc2_1_name, &loc2_2_name, 'K') ;\n%end ;\n\n\n/* Round GeoDistance Value */\n%if &round=1 %then %do ;\n select(&decimalPlaces) ;\n when(0) &newColumn_name=round(distance_in_&disType) ;\n when(1) &newColumn_name=round(distance_in_&disType,0.1) ;\n when(2) &newColumn_name=round(distance_in_&disType,0.01) ;\n when(3) &newColumn_name=round(distance_in_&disType,0.001) ;\n when(4) &newColumn_name=round(distance_in_&disType,0.0001) ;\n when(5) &newColumn_name=round(distance_in_&disType,0.00001) ;\n end;\n%end;\nrun;"}}