BookmarkSubscribeRSS Feed
milts
Pyrite | Level 9

Hi,

I'm just curious with proc groovy. Any thought on any practical applications of this procedure?

Thanks!

Milton

7 REPLIES 7
Cynthia_sas
SAS Super FREQ

Hi:

  As cool as the name is, it seems to me that you need to be using Java to get the most use out of PROC GROOVY:

http://support.sas.com/documentation/cdl/en/proc/63079/HTML/default/viewer.htm#p1x8agymll9gten1oczii...

where it says:

"Groovy is a dynamic language that runs on the Java Virtual Machine (JVM). PROC GROOVY enables SAS code to execute Groovy code on the JVM.

          

PROC GROOVY can run Groovy statements that are written as part of your SAS code, and it can run statements that are in files that you specify with PROC GROOVY commands. It can parse Groovy statements into Groovy Class objects, and run these objects or make them available to other PROC GROOVY statements or Java DATA Step Objects. You can also use PROC GROOVY to update your CLASSPATH environment variable with additional CLASSPATH strings or filerefs to jar files."

cynthia

milts
Pyrite | Level 9

Hi Cynthia,

Can it also be used to read sas datasets and store it in an object like the when using javaobj in a data step? Looking at the examples in the documentation on PROC GROOVY, I just can see on how it will be used by sas programmers. Maybe a little more advanced example could satisfy my curiousity on this.

Hope we can get some of the members of this community post their thoughts on how will it be used practically. Smiley Happy

Milton

JackHamilton
Lapis Lazuli | Level 10

See FriedEgg's example in https://communities.sas.com/message/144937#144937 .

I'm thinking about submitting a SASGloF paper on ZIPping files with PROC GROOVY.  Getting a list of files in a ZIP file might be more practical - ZIPing files is already in base SAS as of 9.2, but reading ZIP files won't be there until 9.4 or later.

FriedEgg
SAS Employee

I have submitted a paper to this coming SGF (2013 - San Fran) which heavily involves using PROC GROOVY for a number of things.  The acceptance is still pending, but the working title is "SAS/ACCESS for iPhone" and will demonstrate how to access data through only base SAS using a number of advanced techniques.  I use PROC GROOVY to perform data hashing and access JDBC data sources and bring the data into SAS, among other things.

There is plenty that can be done with PROC GROOVY and it's addition is nice for programmers, it adds very little that did not already exist however through usage of the java object previously...

To have Java (or Groovy....) read and write directly to/from SAS datasets requires the SAS JDBC drivers and either SAS/SHARE or SAS Integration Technologies.  You can also write classes and methods to help exchange data through SAS using component object without the additional licenses.

JackHamilton
Lapis Lazuli | Level 10

I'm thinking of submitting a paper (I still have two days) on proc groovy for dummies - nowhere near the complexity of what you're talking about (basically, some simple uses of proc groovy that don't require any knowledge of groovy or java).  Your paper sounds very interesting (especially if it talks about error handling).  What section did you submit it to?

I tried some Ant examples I found on the web, and they didn't work because groovy couldn't find AntBuilder.  Do you know if it is not included in SAS, or if it's just a result of me not knowing what I'm doing?

FriedEgg
SAS Employee

It should be part of your standard Java install, but it is probably not included in your environment by default.

proc groovy;

ADD SASJAR="ANT";

submit;

  def ant = new AntBuilder()

  ant.echo("Test")

endsubmit;

run;

JackHamilton
Lapis Lazuli | Level 10

As I suspected, I don't know what I'm doing.  Your ADD statement worked.  Thanks.

sas-innovate-2024.png

Join us for SAS Innovate April 16-19 at the Aria in Las Vegas. Bring the team and save big with our group pricing for a limited time only.

Pre-conference courses and tutorials are filling up fast and are always a sellout. Register today to reserve your seat.

 

Register now!

What is Bayesian Analysis?

Learn the difference between classical and Bayesian statistical approaches and see a few PROC examples to perform Bayesian analysis in this video.

Find more tutorials on the SAS Users YouTube channel.

Click image to register for webinarClick image to register for webinar

Classroom Training Available!

Select SAS Training centers are offering in-person courses. View upcoming courses for:

View all other training opportunities.

Discussion stats
  • 7 replies
  • 4005 views
  • 0 likes
  • 4 in conversation