BookmarkSubscribeRSS Feed
prholland
Fluorite | Level 6
I'm developing an EG 4.1 Add-In using VB.Net. I'm currently using SASVariableSelector.GetAssignedVariable(ROLE,n) to extract the name of a variable in a Role list. Is there a method or property I can use to extract the label of that variable, instead of the name?

.........Phil
3 REPLIES 3
ChrisHemedinger
Community Manager
Phil,

You can use the ISASTaskData and ISASTaskDataColumn interfaces to get this information.

Here is a C# snippet that should translate to VB.NET fairly easily.

[pre]
using SAS.Shared.AddIns;

ISASTaskData data = Consumer.ActiveData;
ISASTaskDataAccessor da = data.Accessor;
// to do that, we need to "open" the data to get a peek at the column
// information
if (da.Open())
{
for (int i=0; i < da.ColumnCount; i++)
{
ISASTaskDataColumn ci = da.ColumnInfoByIndex(i);
cmbReport.Items.Add(ci.Label);
}
da.Close();
}
[/pre]

Chris
SAS For Dummies 3rd Edition! Check out the new edition, covering SAS 9.4, SAS Viya, and all of the modern ways to use SAS!
prholland
Fluorite | Level 6
Chris,

I found something similar to your code in the Compare Add-In code in the VB.Net Samples. Unfortunately, although it works very well when picking up the labels from the underlying data set, if I've changed the label or format in the SAS Variable Selector object, it ignores those changes.

Is there any interface to the SAS Variable Selector object that can give me the changed label or format? If there isn't anything suitable, I might try to include user-editable labels and formats in the SAS Variable Properties object instead.

.........Phil
ChrisHemedinger
Community Manager
Phil,

Have you tried the GetVariablesFormat(string varname) call on the SASVariableSelector control?

You can also subscribe to an event: VariableFormatChanged. With the event you can be notified when the user changes the value. Using GetVariablesFormat(), you can query for the new or current value.

Chris
SAS For Dummies 3rd Edition! Check out the new edition, covering SAS 9.4, SAS Viya, and all of the modern ways to use SAS!

hackathon24-white-horiz.png

The 2025 SAS Hackathon has begun!

It's finally time to hack! Remember to visit the SAS Hacker's Hub regularly for news and updates.

Latest Updates

Creating Custom Steps in SAS Studio

Check out this tutorial series to learn how to build your own steps in SAS Studio.

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