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

Hi all,

This is probably more of a question for Chris, but if anyone knows, I am not sure how to implement custom tasks so that they can read in data from Excel as input. The usual call in C# is to use:

SasData data = new SasData(this.Consumer.InputData[0] as ISASTaskData2

but this assumes the data is SAS based from a library. When you run the task in Excel, and the user chooses Excel data, a window appears that allows the user to select the cells that contain the data of interest, but when the variable selector appears, no data variables appear in the selection, presumably because the Excel data was not able to be read in. A workaround is for the user to first copy the Excel data to the work library, and to run the task on this, but there must be a way of reading in the data as part of the custom task.

Any help appreciated.

Nick

                    );

1 ACCEPTED SOLUTION

Accepted Solutions
ChrisHemedinger
Community Manager

Nick,

In this case, you will need to rely on a different API to get to information about this "unrealized data" -- data that is in the spreadsheet but not yet copied to SAS.  The Office Add-In supports these APIs (as does EG) to surface information about data sources independent of the easier-to-use SasData classes.

The technique uses ISASTaskDataAccessor and ISASTaskDataColumn APIs, which are shown in the Top N Report example in my Custom Tasks book (see Chapter 9).  You can access the sample code in my GitHub repository - see the TopNReportForm.cs file.

Hope this helps,

Chris

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

View solution in original post

2 REPLIES 2
ChrisHemedinger
Community Manager

Nick,

In this case, you will need to rely on a different API to get to information about this "unrealized data" -- data that is in the spreadsheet but not yet copied to SAS.  The Office Add-In supports these APIs (as does EG) to surface information about data sources independent of the easier-to-use SasData classes.

The technique uses ISASTaskDataAccessor and ISASTaskDataColumn APIs, which are shown in the Top N Report example in my Custom Tasks book (see Chapter 9).  You can access the sample code in my GitHub repository - see the TopNReportForm.cs file.

Hope this helps,

Chris

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

Thanks Chris, that worked.

Although the SaSData class is a bit easier to use, the API you mentioned has the advantage of allowing Excel data to be used, without much extra effort.

Nick

sas-innovate-2024.png

Don't miss out on SAS Innovate - Register now for the FREE Livestream!

Can't make it to Vegas? No problem! Watch our general sessions LIVE or on-demand starting April 17th. Hear from SAS execs, best-selling author Adam Grant, Hot Ones host Sean Evans, top tech journalist Kara Swisher, AI expert Cassie Kozyrkov, and the mind-blowing dance crew iLuminate! Plus, get access to over 20 breakout sessions.

 

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