BookmarkSubscribeRSS Feed
🔒 This topic is solved and locked. Need further help from the community? Please sign in and ask a new question.
BartDekeyser
Calcite | Level 5

I am designing a studio task with a multientry. I want all the values that have been added there , can be transferred to a parameter list

 

How can i do that ?

 

so i can say : %let list = $multientry.getArray....

 

In addition is there somewhere a list of all the available VTL classes for each options. 

For example : i know there is a $multientry.size. but where can i find the other classes.

 

 

1 ACCEPTED SOLUTION

Accepted Solutions
BrianGaines
SAS Employee

Hi @BartDekeyser,

 

I know I just responded to your email, but I thought I would cross-post my answer here in case others find it useful.

 

Whenever I have wanted to extract all the values from a list, I’ve done so using a #foreach loop.  I am not aware of a more direct way of obtaining the list, and this is the approach that we generally use in the tasks.   

 

For example, I would use Velocity code such as this.  It first checks to see if the list is empty, and then lists all of the items in the list:

 

#if($multientrytest.size() > 0)
    %let List =#foreach($item in $multientrytest) $item#end;
#end

 

If $multientrytest returns multientry.png, then the above loop would return multientryValues.png.

 

If you still would like for the commas to appear in the list, then this version of the code does that:

 

#if($multientrytest.size() > 0)
    %let List =#foreach($item in $multientrytest) $item#if($foreach.hasNext),#end#end;
#end

 

 

So the result would be multientryValuesCommas.jpg.

 

How exactly do you want the list to appear in the generated code?

 

 

As for your other question, I am not aware of a way to directly list all the available methods/functions available for a certain VTL variable (I’m pretty sure I have asked a Common Task Model developer this question before and he said it wasn’t possible).  For this, I typically use the .getClass() method to find out which java class the VTL variable belongs to.  Once the java class is determined, then you reference the java documentation for that class. For example, $multientrytest.getClass() will return class java.util.ArrayList, and then you can look at the java documentation to see the built-in methods for ArrayLists.

 

Additionally, the SAS Studio task developer’s guide has documentation on additional methods that have been added specifically for writing tasks. For example, there are sections in the documentation with information on additional methods available for DataSource, Role, and OutputData elements.

 

I hope this is helpful. Please let me know if you have any additional questions or if this does not meet your needs.

 

Thanks,

 

-Brian

View solution in original post

1 REPLY 1
BrianGaines
SAS Employee

Hi @BartDekeyser,

 

I know I just responded to your email, but I thought I would cross-post my answer here in case others find it useful.

 

Whenever I have wanted to extract all the values from a list, I’ve done so using a #foreach loop.  I am not aware of a more direct way of obtaining the list, and this is the approach that we generally use in the tasks.   

 

For example, I would use Velocity code such as this.  It first checks to see if the list is empty, and then lists all of the items in the list:

 

#if($multientrytest.size() > 0)
    %let List =#foreach($item in $multientrytest) $item#end;
#end

 

If $multientrytest returns multientry.png, then the above loop would return multientryValues.png.

 

If you still would like for the commas to appear in the list, then this version of the code does that:

 

#if($multientrytest.size() > 0)
    %let List =#foreach($item in $multientrytest) $item#if($foreach.hasNext),#end#end;
#end

 

 

So the result would be multientryValuesCommas.jpg.

 

How exactly do you want the list to appear in the generated code?

 

 

As for your other question, I am not aware of a way to directly list all the available methods/functions available for a certain VTL variable (I’m pretty sure I have asked a Common Task Model developer this question before and he said it wasn’t possible).  For this, I typically use the .getClass() method to find out which java class the VTL variable belongs to.  Once the java class is determined, then you reference the java documentation for that class. For example, $multientrytest.getClass() will return class java.util.ArrayList, and then you can look at the java documentation to see the built-in methods for ArrayLists.

 

Additionally, the SAS Studio task developer’s guide has documentation on additional methods that have been added specifically for writing tasks. For example, there are sections in the documentation with information on additional methods available for DataSource, Role, and OutputData elements.

 

I hope this is helpful. Please let me know if you have any additional questions or if this does not meet your needs.

 

Thanks,

 

-Brian

sas-innovate-2024.png

Available on demand!

Missed SAS Innovate Las Vegas? Watch all the action for free! View the keynotes, general sessions and 22 breakouts on demand.

 

Register now!

SAS Enterprise Guide vs. SAS Studio

What’s the difference between SAS Enterprise Guide and SAS Studio? How are they similar? Just ask SAS’ Danny Modlin.

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
  • 1 reply
  • 372 views
  • 1 like
  • 2 in conversation