BookmarkSubscribeRSS Feed
Victor
Calcite | Level 5
Hello

I need to know how to implement and to use ISASTaskDataSink class. With a sample code, it will be perfect.

The custom task that i develop does not use any SAS code, but generates, however, some SAS tables in existant libraries. I need to insert these tables in the project.

Thank's
11 REPLIES 11
ChrisHemedinger
Community Manager
Victor,

I can supply some sample code, but first: are you developing this for EG 4.1 or 4.2?

Chris
It's time to register for SAS Innovate! Join your SAS user peers in Las Vegas on April 16-19 2024.
Victor
Calcite | Level 5
For EG 4.1.

Is there a difference? Soon, we will migrate for 4.2.


Thnak's
ChrisHemedinger
Community Manager
Victor,

If all you need to do is add data to the project, your task can do this by using the ISASTask.OutputDataCount and ISASTask.OutputDataInfo methods. Here is an example to add SASHELP.CLASS from the current server:

[pre]
public int OutputDataCount
{
get { return 1; }
}

public SAS.Shared.AddIns.OutputData OutputDataInfo(int Index, out string Source, out string Label)
{
string server = _consumer.AssignedServer; // ISASTaskConsumer reference
string libref="SASHELP";
string member="CLASS";
Source = string.Format(@"SAS:\Dataset\{0}\{1}\{2}", server, libref, member);
Label = "SASHELP.CLASS";
return SAS.Shared.AddIns.OutputData.SdsName;
}
[/pre]

ISASTaskDataSink is used as a notification from the application that your input data has changed, or that your task should consider generating new names for output data (in the scenario where a task is being re-run, and the user has selected "No" for the "Replace existing results?" question).

Chris
It's time to register for SAS Innovate! Join your SAS user peers in Las Vegas on April 16-19 2024.
Victor
Calcite | Level 5
Thanks for your rapid answer


Ok. I tried before to use this method under VB with no succes. (I use VB for Custom Task)

Your code gaves me an idea. I tried it under VB and C#. Under VB, no way, it still not working. Under C#, it works fine. Curious

Note:
I changed under both languages the property "RunLog" to return some text and the property "GeneratesSasCode" to return False.


Some explenations ???
Victor
Calcite | Level 5
Sorry

I was not exactly the same method. I tried to use

OutputDataInfo=OutputData.Libref.

It does not works, probably because i don't know the exact syntax.

Can you give me the exact syntax for this also?


Thank's a lot for every thing
Victor
Calcite | Level 5
One more question.

If there is more than one table, what is the exact syntax ?



Thank's
Victor
Calcite | Level 5
It's Ok now. For more then one table, i found it. I use the Index to return different tables.

Thanks
ChrisHemedinger
Community Manager
Some explanation:

You use the SAS.Shared.AddIns.OutputData.Libref in the "normal" case, when your task generates a SAS program that, when EG runs it on the assigned SAS server, creates/modifies data that you can refer to using the LIBREF.MEMBER syntax.

But in your case, the task isn't running a SAS program to create the data. It's doing something else behind the scenes (I don't know what; that's your secret sauce). But you want to make sure that EG adds the new data to the project after the task is run, so you can supply the full reference with the SAS.Shared.AddIns.OutputData.SdsName reference. We don't document the SdsName schema (that's part of our secret sauce), but this example of building a data set reference should cover the majority of the use cases that folks come up with.

Chris
It's time to register for SAS Innovate! Join your SAS user peers in Las Vegas on April 16-19 2024.
Victor
Calcite | Level 5

Hello

I'm back because i need help. I'm writing some Custom Tasks for Enterprise Guide 4.3.

I'm using for that, Visual Studio 2008 with the template SAS.Tasks.VBTemplate42 delivered by SAS.

But i notice that the property "OutputDataCount" is ReadOnly and the function "OutputDataInfo" is impossible to override because it is not declared Overridable.

How can i write what was written for Guide 4.1 listed in this discussion ?

Will I have to write everything without using the template ?

In this case, what's the point of the template ?

Where can i find detailed documentations ?

Thank's

ChrisHemedinger
Community Manager

Victor,

In the template, the SasTask class now implements many of the mundane parts of the task API contract.  You override just the parts that your task needs.  As a result, you'll have many fewer lines of code that deal with the ISASTask* implementation.

To control your output data count, you override the OutputDataCount property in your task class, and return the number that is correct for your task. 

And you override the OutputDataDescriptorList property to return more details:

        public override int OutputDataCount
        {
            get { return 1; }
        }

        // build the output description for the data set
        public override System.Collections.Generic.List OutputDataDescriptorList
        {
            get
            {
                System.Collections.Generic.List outList = 
                    new System.Collections.Generic.List();

                string[] parts = settings.OutputData.Split(new char[] { '.' });
                if (parts.Length == 2)
                {
                    outList.Add(
                        // use this helper method to build the output descriptor
                        SAS.Shared.AddIns.SASTaskDataDescriptor.CreateLibrefDataDescriptor(
                            Consumer.AssignedServer, parts[0], parts[1], "")
                        );
                }
                return outList;
            }
        }

Let me know if you need a VB.NET example of this.

Chris

It's time to register for SAS Innovate! Join your SAS user peers in Las Vegas on April 16-19 2024.
Victor
Calcite | Level 5

Hello

Indeed, it has changed from the 4.1. Without your help, I would never have found.

That's why i'm very interested in any document or sample on Custmer Tasks, because I do a lot of them.  It is very difficult to find something on them.

Thank's

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!

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
  • 11 replies
  • 1453 views
  • 0 likes
  • 2 in conversation