Help using Base SAS procedures

PROC Groovy Submit Command failed

Super Contributor
Posts: 250

PROC Groovy Submit Command failed

Hi all!  Nothing better than trying to debug SAS Code on a Saturday afternoon Smiley Happy


I'm just starting to dig into Twitter analytics with PROC Groovy, using a blog post that I found by Falko Schulz (here) and @FriedEgg's posts through the community, but I'm stuck.


Here's the code that is giving me the problem:


 proc groovy classpath="C:/bookdata/TwitterAnalysis/groovy-all-2.3.4.jar";
add classpath="C:/bookdata/TwitterAnalysis/opencsv-3.8.jar";
   submit "&JSON_TWEET_FILE." "&CSV_TWEET_FILE."; 
      import groovy.json.*;
      def input = new File(args[0]).text;
      def output = new JsonSlurper().parseText(input);
      def csvoutput = new FileWriter(args[1]);
      CSVWriter writer = new CSVWriter(csvoutput);
      String[] header = new String[15];
      header[0] = "id";
      header[1] = "text";
      header[2] = "truncated";
      header[3] = "created_at";
      header[4] = "";
      header[5] = "";
      header[6] = "user.screen_name";
      header[7] = "user.location";
      header[8] = "user.description";
      header[9] = "user.url";
      header[10] = "user.followers_count";
      header[11] = "user.friends_count";
      header[12] = "user.listed_count";
      header[13] = "retweet_count";
      header[14] = "favorite_count";
      output.statuses.each {
         String[] content = new String[15];
         content[0] =;
         content[1] = it.text.toString();
         content[2] = it.truncated.toString();
         content[3] = it.created_at.toString();
         content[4] =;
         content[5] =;
         content[6] = it.user.screen_name.toString();
         content[7] = it.user.location.toString();
         content[8] = it.user.description.toString();
         content[9] = it.user.url.toString();
         content[10] = it.user.followers_count.toString();
         content[11] = it.user.friends_count.toString();
         content[12] = it.user.listed_count.toString();
         content[13] = it.retweet_count.toString();
         content[14] = it.favorite_count.toString();

Based on the troubleshooting tips from @FriedEgg and others, I was able to figure out for example i needed to change \ to / in my file locations.  The orginal article also had the Classpaths for the two JAR files in the same classpath statement, but I am still getting the same error:  Nothing else in the code was changed from the orignal.


ERROR: The SUBMIT command failed.
org.codehaus.groovy.control.MultipleCompilationErrorsException: startup failed:
Script44.groovy: 2: unable to resolve class
 @ line 2, column 7.

1 error

     at org.codehaus.groovy.control.ErrorCollector.failIfErrors(
     at org.codehaus.groovy.control.CompilationUnit.applyToSourceUnits(
     at org.codehaus.groovy.control.CompilationUnit.doPhaseOperation(
     at org.codehaus.groovy.control.CompilationUnit.compile(
     at groovy.lang.GroovyClassLoader.parseClass(
     at groovy.lang.GroovyShell.parseClass(
     at groovy.lang.GroovyShell.parse(
     at groovy.lang.GroovyShell.parse(
     at groovy.lang.GroovyShell.parse(
3303   quit;

So from what I gather, it's something to do with the opencsv JAR file, but I've tried the newest version (3.8) the one in the orginal article (2.3) as well as the most recent groovy-all JAR (2.3.4) and again the one refered to in the blog (2.2.1).  



The other PROC Groovy in the code seems to run fine, but it is doing something with the JSON file rather than with the CSV.


Any thoughts? 

Thanks so much for your time!


Has my article or post helped? Please mark as Solution or Like the article!
Trusted Advisor
Posts: 1,318

Re: PROC Groovy Submit Command failed

Posted in reply to DarthPathos

The most likely answer is simply that you are not using the correct name for the class in your import statement.  Versions are important and you are using version 3.8 of opencsv, whereas the code you copied was using version 2.3.  During the time between these versions the package name was changed making the class name you are looking for in the version 3.8 Jar file "com.opencsv.CSVWriter"

Super Contributor
Posts: 250

Re: PROC Groovy Submit Command failed

Hi @FriedEgg! Thanks for the reply.   I've tried groovy-all-2.2.1 and 2.3.8, and opencsv-2.3 and 3.8 in all 4 combinations and get the same error.  I am off travelling tomorrow and not back until Saturday so probably won't have a chance to look at this again until next weekend.


Thanks so much for your help - have a great day!


Has my article or post helped? Please mark as Solution or Like the article!
Ask a Question
Discussion stats
  • 2 replies
  • 2 in conversation