SAS Studio

Write and run SAS programs in your web browser
BookmarkSubscribeRSS Feed
🔒 This topic is solved and locked. Need further help from the community? Please sign in and ask a new question.
jamesBFD
Obsidian | Level 7

I've got a custom task that generates a dataset. I'm using Proc Print to display it but I'd really like for the OUTPUT DATA tab to appear as well.

 

If I run the exact same code just as a Program then I get that tab. Is there anyway for it to appear when its a custom task?

 

Thanks.

1 ACCEPTED SOLUTION

Accepted Solutions
BrianGaines
SAS Employee

@jamesBFD,

 

One of the controls/widgets/input types that can be used in a task is the "outputdata" control, which needs to be defined and incorporated in the task XML.  A user can use this to specify the name of an output data set that will be created when the task is submitted. 

 

The same could effectively be accomplished with regular inputtext input type, but the output data control has some additional functionality that is specifically useful for output data sets.  For example, you have the ability to browse the library where you want to save the data set, and it will also throw a warning if there is an existing data set with the same two-level name.  

 

The object generated by the output data control can then be incorporated into the task's generated code as appropriate for the data set to be created (such as in a DATA step or in the OUTPUT statement of a procedure).  

 

An example that sounds somewhat similar to what you have described so far can be seen in the "Transform Data" task in the Data category.  To see this, open the task --> select a data set (such as SASHELP.CARS) --> assign a variable to the Variable 1 role (such as MSRP from SASHELP.CARS) --> open the OUTPUT DATA SET group --> Select "Show output data" in the "Show Output Data" group.  Your screen should look like this:

transformData.PNG

 

You can see that this task generates a new data set and also displays part of its contents using the PRINT procedure.  The name of the data set (transform) is specified using the output data control (which is highlighted by a blue box), which then appears in the DATA statement as WORK.transform (since a single-level data set name was specified, the task assumes the library is WORK).  

 

After you submit this code, the results from proc PRINT are initially displayed, but you see that there is also an OUTPUT DATA tab which contains the newly-created WORK.transform data set:

transformDataOutput.PNG

 

Is this what you are looking for? 

 

If so, then the easiest thing would probably be to look at the underlying XML code for the Transform Data task and copy what you need to incorporate it into your task.  It may not be obvious, but it's possible to see/edit the XML code for a task after it's copied to your "My Tasks" folder.  That is, right click on the Transform Data task --> "Add to My Tasks" --> Click Add --> Go to My Tasks --> Right click on the Transform Data task --> Edit.  This opens the underlying XML code for the task.  

 

If you have any questions or this still does not solve the issue, please let me know.

 

Best,

 

-Brian

 

View solution in original post

6 REPLIES 6
BrianGaines
SAS Employee

Hi @jamesBFD,

 

This is something I have discussed with the team that supports the custom task model (CTM) for the tasks, and what you are observing is done by design.  

 

When you run a task, only the data sets that were specified in an output data control will appear in the OUTPUT DATA tab.  The thought is that those data sets are the ones of primary interest, so only those display in the OUTPUT DATA tab to keep it from being cluttered with intermediate data sets that presumably are not of interest (at least in general).  

 

So you could add an output data control to your task that specifies the name for this data set.  Then, when you run the task, it will appear in the OUTPUT DATA tab.

 

Would specifying the data set in an output data control be an option for your use case?

 

Thanks,

 

-Brian

jamesBFD
Obsidian | Level 7

@BrianGainesthanks for the reply.

 

Yes from your description that does seem like it would work.

 

I am however a little unclear about how exactly this OUTPUT DATA tab works, specifically where do I define what the data set is for this tab? Is this something that needs defining in the Task XML or is done via the OUTPUT statement in SAS code, e.g. this statement?

 

If you could give a brief example I'd be most grateful.

 

Thanks.

BrianGaines
SAS Employee

@jamesBFD,

 

One of the controls/widgets/input types that can be used in a task is the "outputdata" control, which needs to be defined and incorporated in the task XML.  A user can use this to specify the name of an output data set that will be created when the task is submitted. 

 

The same could effectively be accomplished with regular inputtext input type, but the output data control has some additional functionality that is specifically useful for output data sets.  For example, you have the ability to browse the library where you want to save the data set, and it will also throw a warning if there is an existing data set with the same two-level name.  

 

The object generated by the output data control can then be incorporated into the task's generated code as appropriate for the data set to be created (such as in a DATA step or in the OUTPUT statement of a procedure).  

 

An example that sounds somewhat similar to what you have described so far can be seen in the "Transform Data" task in the Data category.  To see this, open the task --> select a data set (such as SASHELP.CARS) --> assign a variable to the Variable 1 role (such as MSRP from SASHELP.CARS) --> open the OUTPUT DATA SET group --> Select "Show output data" in the "Show Output Data" group.  Your screen should look like this:

transformData.PNG

 

You can see that this task generates a new data set and also displays part of its contents using the PRINT procedure.  The name of the data set (transform) is specified using the output data control (which is highlighted by a blue box), which then appears in the DATA statement as WORK.transform (since a single-level data set name was specified, the task assumes the library is WORK).  

 

After you submit this code, the results from proc PRINT are initially displayed, but you see that there is also an OUTPUT DATA tab which contains the newly-created WORK.transform data set:

transformDataOutput.PNG

 

Is this what you are looking for? 

 

If so, then the easiest thing would probably be to look at the underlying XML code for the Transform Data task and copy what you need to incorporate it into your task.  It may not be obvious, but it's possible to see/edit the XML code for a task after it's copied to your "My Tasks" folder.  That is, right click on the Transform Data task --> "Add to My Tasks" --> Click Add --> Go to My Tasks --> Right click on the Transform Data task --> Edit.  This opens the underlying XML code for the task.  

 

If you have any questions or this still does not solve the issue, please let me know.

 

Best,

 

-Brian

 

logbaseten
Fluorite | Level 6

Crazy timing!  I was searching for a remedy to basically the same thing.   

 

I appreciate the long and detailed reply -- I had no idea you could look at the code for an existing task, that is very useful.  You deserve a raise!

jamesBFD
Obsidian | Level 7

Thanks @BrianGaines, this worked perfectly, giving me exactly what I needed.

BrianGaines
SAS Employee

No problem, @jamesBFD, I'm glad to help!  And it's great to hear that it solved your problem!  

sas-innovate-white.png

Our biggest data and AI event of the year.

Don’t miss the livestream kicking off May 7. It’s free. It’s easy. And it’s the best seat in the house.

Join us virtually with our complimentary SAS Innovate Digital Pass. Watch live or on-demand in multiple languages, with translations available to help you get the most out of every session.

 

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.

SAS Training: Just a Click Away

 Ready to level-up your skills? Choose your own adventure.

Browse our catalog!

Discussion stats
  • 6 replies
  • 4004 views
  • 3 likes
  • 3 in conversation