Friedegg, Thanks so much for your code and thoughts on this problem. I made your suggested changes, but still cannot get the code to run. Note I tried using both the groovy-all jar that was installed with SAS and a newer version. I got the same error in both cases. -Bill Log: 1661 dm 'clear log'; 1662 1663 options mprint; 1664 1665 filename cp temp; 1666 1667 proc 1667! groovy classpath=cp; NOTE: The ADD CLASSPATH command completed. 1668 1669 add classpath="C:\Program Files (x86)\Groovy\Groovy-2.4.0\lib\groovy-all.2.4.0.jar"; NOTE: The ADD CLASSPATH command completed. 1670 1671 submit parseonly; 1672 import groovy.json.JsonSlurper 1673 class MyJsonParser { 1674 def parseFile(path) { 1675 def jsonFile = new File(path) 1676 def jsonText = jsonFile.getText() 1677 def InputJSON = new JsonSlurper().parseText(jsonText) 1678 def accounts = [] 1679 1680 1681 InputJSON.results.each{ 1682 accounts << [ 1683 acct_nbr : it.acct_nbr.toString(), 1684 firstName : it.firstName, 1685 lastName : it.lastName, 1686 age : it.age.toString(), 1687 streetAddress : it.address.streetAddress, 1688 city : it.address.city, 1689 state : it.address.state, 1690 postalCode : it.address.postalCode 1691 ] 1692 } 1693 1694 1695 return accounts 1696 } 1697 } 1698 endsubmit; ERROR: The SUBMIT command failed. org.codehaus.groovy.control.MultipleCompilationErrorsException: startup failed: script14252651249521306453411.groovy: 1: unable to resolve class groovy.json.JsonSlurper @ line 1, column 1. import groovy.json.JsonSlurper ^ 1 error at org.codehaus.groovy.control.ErrorCollector.failIfErrors(ErrorCollector.java:296) at org.codehaus.groovy.control.CompilationUnit.applyToSourceUnits(CompilationUnit.java:860) at org.codehaus.groovy.control.CompilationUnit.doPhaseOperation(CompilationUnit.java:521) at org.codehaus.groovy.control.CompilationUnit.processPhaseOperations(CompilationUnit.java:497) at org.codehaus.groovy.control.CompilationUnit.compile(CompilationUnit.java:474) at groovy.lang.GroovyClassLoader.parseClass(GroovyClassLoader.java:292) at groovy.lang.GroovyClassLoader.parseClass(GroovyClassLoader.java:263) at groovy.lang.GroovyClassLoader.parseClass(GroovyClassLoader.java:207) at groovy.lang.GroovyClassLoader.parseClass(GroovyClassLoader.java:217) 1699 1700 1701 submit parseonly; 1702 import java.util.ArrayList; 1703 import java.util.Iterator; 1704 import java.util.LinkedHashMap; 1705 1706 1707 public class MyJsonParser4Sas { 1708 public String filename = ""; 1709 1710 1711 public void init() { 1712 MyJsonParser myParser = new MyJsonParser(); 1713 accounts = myParser.parseFile(filename); 1714 iter = accounts.iterator(); 1715 } 1716 1717 1718 public boolean hasNext() { 1719 return iter.hasNext(); 1720 } 1721 1722 1723 public void getNext() { 1724 account = ((LinkedHashMap) (iter.next())); 1725 } 1726 1727 1728 public String getString(String k) { 1729 return account.get(k); 1730 } 1731 1732 1733 protected ArrayList accounts; 1734 protected Iterator iter; 1735 protected LinkedHashMap account; 1736 } 1737 endsubmit; ERROR: The SUBMIT command failed. org.codehaus.groovy.control.MultipleCompilationErrorsException: startup failed: script1425265124971621978172.groovy: 11: unable to resolve class MyJsonParser @ line 11, column 22. MyJsonParser myParser = new MyJsonParser(); ^ script1425265124971621978172.groovy: 11: unable to resolve class MyJsonParser @ line 11, column 33. MyJsonParser myParser = new MyJsonParser(); ^ 2 errors at org.codehaus.groovy.control.ErrorCollector.failIfErrors(ErrorCollector.java:296) at org.codehaus.groovy.control.CompilationUnit.applyToSourceUnits(CompilationUnit.java:860) at org.codehaus.groovy.control.CompilationUnit.doPhaseOperation(CompilationUnit.java:521) at org.codehaus.groovy.control.CompilationUnit.processPhaseOperations(CompilationUnit.java:497) at org.codehaus.groovy.control.CompilationUnit.compile(CompilationUnit.java:474) at groovy.lang.GroovyClassLoader.parseClass(GroovyClassLoader.java:292) at groovy.lang.GroovyClassLoader.parseClass(GroovyClassLoader.java:263) at groovy.lang.GroovyClassLoader.parseClass(GroovyClassLoader.java:207) at groovy.lang.GroovyClassLoader.parseClass(GroovyClassLoader.java:217) 1738 1739 1740 quit; NOTE: The SAS System stopped processing this step because of errors. NOTE: PROCEDURE GROOVY used (Total process time): real time 0.04 seconds cpu time 0.01 seconds 1741 1742 1743 options set=classpath "%sysfunc(pathname(cp,f))"; 1744 filename json "/C:/json.txt"; 1745 1746 1747 data accounts; 1748 attrib id label="Account Index" length= 8 1749 acct_nbr label="Account Number" length=$ 10 1750 firstName label="First Name" length=$ 20 1751 lastName label="Last Name" length=$ 30 1752 age label="Age" length=$ 3 1753 streetAddress label="Street Address" length=$ 128 1754 city label="City" length=$ 40 1755 state label="State" length=$ 2 1756 postalCode label="Postal Code" length=$ 5; 1757 1758 1759 dcl javaobj accounts("MyJsonParser4Sas"); 1760 accounts.exceptiondescribe(1); 1761 1762 1763 accounts.setStringField("filename", "%sysfunc(pathname(json,f))"); 1764 1765 1766 accounts.callVoidMethod("init"); 1767 1768 1769 accounts.callBooleanMethod("hasNext",rc); 1770 do id=1 by 1 while(rc); 1771 accounts.callVoidMethod("getNext"); 1772 accounts.callStringMethod("getString", "acct_nbr", acct_nbr); 1773 accounts.callStringMethod("getString", "firstName", firstName); 1774 accounts.callStringMethod("getString", "lastName", lastName); 1775 accounts.callStringMethod("getString", "age", age); 1776 accounts.callStringMethod("getString", "streetAddress", streetAddress); 1777 accounts.callStringMethod("getString", "city", city); 1778 accounts.callStringMethod("getString", "state", state); 1779 accounts.callStringMethod("getString", "postalCode", postalCode); 1780 output; 1781 accounts.callBooleanMethod("hasNext",rc); 1782 end; 1783 1784 drop rc; 1785 run; ERROR: Could not find class MyJsonParser4Sas at line 1759 column 24. Please ensure that the CLASSPATH is correct. ERROR: DATA STEP Component Object failure. Aborted during the EXECUTION phase. java.lang.ClassNotFoundException: MyJsonParser4Sas at java.net.URLClassLoader$1.run(Unknown Source) at java.security.AccessController.doPrivileged(Native Method) at java.net.URLClassLoader.findClass(Unknown Source) at java.lang.ClassLoader.loadClass(Unknown Source) at groovy.lang.GroovyClassLoader.loadClass(GroovyClassLoader.java:674) at groovy.lang.GroovyClassLoader.loadClass(GroovyClassLoader.java:773) at java.lang.ClassLoader.loadClass(Unknown Source) NOTE: The SAS System stopped processing this step because of errors. WARNING: The data set WORK.ACCOUNTS may be incomplete. When this step was stopped there were 0 observations and 9 variables. WARNING: Data set WORK.ACCOUNTS was not replaced because this step was stopped. NOTE: DATA statement used (Total process time): real time 0.01 seconds cpu time 0.01 seconds
... View more