Desktop productivity for business analysts and programmers

How do you find a label of a variable in EG 4.1 Add-Ins?

Reply
Frequent Contributor
Posts: 81

How do you find a label of a variable in EG 4.1 Add-Ins?

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
Community Manager
Posts: 2,696

Re: How do you find a label of a variable in EG 4.1 Add-Ins?

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
Frequent Contributor
Posts: 81

Re: How do you find a label of a variable in EG 4.1 Add-Ins?

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
Community Manager
Posts: 2,696

Re: How do you find a label of a variable in EG 4.1 Add-Ins?

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
Ask a Question
Discussion stats
  • 3 replies
  • 121 views
  • 0 likes
  • 2 in conversation