Customizing Enterprise Guide

Creating Add-Ins

  1. Overview
  2. What is a COM Add-In?
  3. Building COM Add-Ins
  4. Adding, Viewing, and Removing COM Add-Ins
  5. COM Add-In Interfaces
  6. Visual Basic Application Programming Interface
  7. Visual Basic Summary Statistics Code Example

Overview

You can increase the capabilities of Enterprise Guide by creating add-ins. An add-in extends an application by adding functionality that is not in the core product.

You can create Component Object Model (COM) add-ins. Two examples of COM add-ins are wizards (code tasks) and libraries (stored code). Wizards help users through a complex process step by step. In code libraries, you can store frequently used procedures and generic code to be run without interaction from the user.

What is a COM Add-In?

A COM add-in is a dynamic-link library (DLL) that is registered for loading by Enterprise Guide. You can create COM add-ins with Microsoft Visual Basic, Microsoft Visual C++, or any other development environment that supports COM. For more information about these development tools, see the Microsoft Developer Network Web site at http://msdn.microsoft.com.

Building COM Add-Ins

A COM add-in consists a set of interfaces that must be implemented to enable Enterprise Guide to establish a connection with the COM add-in control. The ISEGAddIn, ISEGTask, ISEGTaskInfo, ISEGSubmitSink, ISEGErrorSink, and ISEGDataSink interface, as well as other Enterprise Guide framework interfaces and associated enums, are provided in the SASAIOBJ type library. The interfaces contain preconfigured procedure templates and their parameter lists.

The ISEGAddIn interface contains four methods:
  • Connect

  • Disconnect

  • GetName

  • GetDescription.

While these are methods to the ISEGAddIn interface, to a Visual Basic programmer they act and behave like events. When an add-in is connected to Enterprise Guide, the Connect method is called automatically, similar to an event firing. When the add-in is disconnected, the Disconnect method is called automatically. This behavior holds true for the ISEGTask, ISEGTaskInfo, and the optional ISEGSubmitSink, ISEGErrorSink, and ISEGDataSink interfaces.

Note Because an interface is a contract between an object and Enterprise Guide, be sure to implement all methods in the interfaces. All interface methods must be present in your Class module, with each method containing at least one executable statement that can consist of as little as a single remark statement.

To build a COM add-in
  1. Open Visual Basic and create a new ActiveX DLL project. Name the project MyAddIn. Name the public class Custom or give it a name that indicates its purpose. A ProgID named MyAddIn.Custom is created that will be used to register the new add-in. Refer to the Microsoft Developer Network Web site at http://msdn.microsoft.com for information on ProgIds.

  2. Select Project [image] References. In the References dialog box, add a reference to the SAS: Enterprise Guide Add-In Object Model Type Library. The type library is a file named SASAIOBJ.dll or SASAIOBJ.tlb, located in the \Program Files\SAS Institute\Enterprise Guide folder.

  3. Use the Implements statement to generate the appropriate method template for the interface. To do this, enter the following code in the Declarations section of the Class module that provides the add-in's connection object:
    Implements SEGAddIn
Implements SEGTask
Implements SEGTaskInfo
    4. An interface's methods are exposed through the Implements statement. When the syntax above is entered in the Declarations section of the Class module that handles an add-in's events, the interface's methods become available for use through the module's Procedure and Object drop-down boxes.

  4. Select SEGAddIn from the module's Object drop-down box. Select each method from the Procedure box to add the procedure template to the class. The necessary code is automatically added to the Class module. Each method must be implemented, regardless of whether the method performs any function or sets any value.

  5. Build the project to create the DLL.

Adding, Viewing, and Removing COM Add-Ins

To add a COM add-in and view the list of available add-ins

  1. Open Enterprise Guide and select Tools [image] Customize

  2. Click the Add-Ins tab.

  3. Click the Add button.

  4. In the Register Add-In dialog box, type the ProgID and click OK. The add-in DLL is registered and the add-in is displayed in the list of available add-ins.

  5. In the Add-Ins available list, click the check box next to the new add-in to load it. To unload an add-in, clear the check box. Loading a COM add-in loads it into memory so that you can work with it. Unloading an add-in removes it from memory; you cannot use the add-in until you load it again.

  6. Click OK to close the Customize dialog box.

  7. Restart Enterprise Guide to cause your changes to take effect.
To remove a COM add-in

  1. Select the add-in from the Add-Ins available list.

  2. Click the Remove button. Removing an add-in deletes the registry key that contains the name and load behavior of the add-in. Like any other DLL, the add-in's DLL is registered as a unique object on the system. Additionally, information about the add-in is in another section of the registry to notify Enterprise Guide that the add-in exists. This section is deleted when you remove an add-in from the list. The DLL itself remains registered, and if you add the add-in to the list again, the add-in's information section is re-created in the registry.

  3. Restart Enterprise Guide to cause your changes to take effect.

COM Add-In Interfaces

COM add-in interfaces must be implemented in both Enterprise Guide and the third-party COM add-in control. A type library defines interfaces that need to be implemented by the third-party control.

COM add-in interfaces have the following object hierarchy:

The following interfaces are provided with Enterprise Guide to enable you to write custom tasks that are integrated with the existing Enterprise Guide architecture.

AddIn Object

This interface is implemented by the add-in control. It is the initial connection point that Enterprise Guide uses to determine if it can support the component. Components are intended to be visual or non-visual.

interface ISEGAddIn : IUnknown {
    [id(1] HRESULT Connect([in] ISEGApplication* ppiApplication,
[in] long lCookie, [out] long* plSuccess );
    [id(2)] HRESULT Disconnect();
    [id(3)] HRESULT GetName( [out] BSTR* pbstrVal );
    [id(4)] HRESULT GetDescription( [out] BSTR* pbstrVal );
};

Task Object

This interface is implemented by the add-in control. The interface is called from the Enterprise Guide internal framework to determine the behavior and action to take when invoked from the application.

interface ISEGTask : IUnknown {
    [id(1)] HRESULT Show( [in] long lParentWindowHandle, [in][out] long* plStatus );
    [id(2)] HRESULT GetPropertyList( [out] SAFEARRAY(BSTR)* pbstrKeyArray );
    [id(3)] HRESULT GetProperty( [in] BSTR bstrKey, [out] BSTR* pbstrVal );
    [id(4)] HRESULT SetProperty( [in] BSTR bstrKey, [out] BSTR bstrVal );
    [id(5)] HRESULT GetSubmitCode( [out] BSTR* pbstrCode );
    [id(6)] HRESULT GetRunLog( [out] BSTR* pbstrVal );
    [id(7)] HRESULT GetOptionsFlag( [out] long* plOptions );
    [id(8)] HRESULT GetRequiresData( [out] long* plVal );
    [id(9)] HRESULT GetOutputDataCount( [out] long* plCount );
    [id(10)] HRESULT GetOutputDataInfo( [in] long lIndex, [out] BSTR* pbstrSource,
[out] BSTR* pbstrLabel,  [out] long* plFile );
    [id(11)] HRESULT Initialize( [in] long* plSuccess );
    [id[12)] HRESULT Terminate();

};

Task Information Object

This interface is implemented by the add-in control. It is required when the add-in is an Enterprise Guide Custom Task. Implementing this interface enables the add-in to integrate seamlessly with the other tasks that are already part of the Enterprise Guide core development system.

interface ISEGTaskInfo : IUnknown {
    [id(1)] HRESULT GetTaskName( [out] BSTR* pbstrVal );
    [id(2)] HRESULT GetTaskDescription( [out] BSTR* pbstrVal );
    [id(3)] HRESULT GetTaskCategory( [out] BSTR* pbstrVal );
    [id(4)] HRESULT GetTaskProcsUsed( [out] BSTR* pbstrVal );
    [id(5)] HRESULT GetTaskMajorVersion( [out] long* plVal );
    [id(6)] HRESULT GetTaskMinorVersion( [out] long* plVal );
    [id(7)] HRESULT GetTaskValidation( [out] BSTR* pbstrVal );
    [id(8)] HRESULT GetTaskType( [out] long* plType );
};

Submit Sink Object

This optional interface is implemented by the add-in control. The interface is called from the Enterprise Guide internal framework. This is a mechanism for the Enterprise Guide internal framework to communicate processing status back to the task in the event that it submitted code to SAS in an intermediate code creation step.

interface ISEGSubmitSink : IUnknown {
    [id(1)] HRESULT SubmitComplete( [in] long lSubmitCookie, [in] long lSuccess );
    [id(2)] HRESULT SubmitError( [in] long lSubmitCookie, [in] long lErrorCode,
[in] BSTR bstrErrorString );
};

Error Sink Object

This optional interface is implemented by the add-in control. The interface is called from the Enterprise Guide internal framework. This is a mechanism for the Enterprise Guide internal framework to communicate an error and detailed information about the error back to the task for handling.

interface ISEGErrorSink : IUnknown {
[id(1)] HRESULT ExecutionError([in] long lErrorCode, [in] BSTR bstrDescription,
[in] BSTR bstrProgID, [in] BSTR bstrMethod, [in] BSTR bstrParameter );
};

Data Sink Object

This optional interface is implemented by the add-in control. The interface is called from the Enterprise Guide internal framework. This is a mechanism for the Enterprise Guide internal framework to communicate a change in the input data or a notification to update output data information.

interface ISEGDataSink : IUnknown {
[id(1)] HRESULT GenerateOutputData( [out] long* plSuccess );
    [id(2)] HRESULT ActiveDataChanged();
    [id(3)] HRESULT GenerateOutputDataNames();
};

Application Object

This interface is implemented by Enterprise Guide. It surfaces core functionality in the Enterprise Guide internal framework. It is also the mechanism for submitting code to SAS outside of the normal code-submit process.

interface ISEGApplication : IUnknown  {
[id(1)] HRESULT Language( [out, retval] long* lVal );
    [id(2)] HRESULT GetOption( [in] long lOptionCode, [out, retval] VARIANT* pvarVal );
    [id(3)] HRESULT GetActiveData( [out, retval] ISEGData** ppiData );
    [id(4)] HRESULT GetServerList( [out] SAFEARRAY(BSTR)* pbstrServerArray);
    [id(5)] HRESULT GetLibraryList( [in] BSTR bstrServer,
[out] SAFEARRAY(BSTR)* pbstrLibraryArray);
    [id(6)] HRESULT GetWorkspace( [in] BSTR bstrServer, [out, retval] IUnknown** ppiWorkspace );
    [id(7)] HRESULT SubmitCode( [in] BSTR bstrCode, [in] BSTR bstrServer, [in] long lAsync,
[out, retval] long* plSubmitCookie );
    [id(8)] HRESULT CancelSubmit( [in] long lSubmitCookie );
    [id(9)] HRESULT GetValidLiteral( [in] BSTR bstrInVal, [out, retval] BSTR* pbstrOutVal );
    [id(10)] HRESULT GetNextVariable( [in] BSTR bstrInBuffer, [out] BSTR* pbstrOutBuffer,
[out, retval] BSTR* pbstrVal );
    [id(11)] HRESULT CreateMemberName( [in] BSTR bstrServer, [in] BSTR bstrLibref,
[in] BSTR bstrRoot, [out, retval] BSTR* pbstrUniqueMember );
    [id(12)] HRESULT CreateDataObject( [in] BSTR bstrServer, [in] BSTR bstrLibref,
[in] BSTR bstrMember, [in] BSTR bstrProviderSrc, [out, retval] ISEGData** ppiData );
};

[id(13)] HRESULT AssignServer( [in] BSTR bstrServer, [out, retval] VARIANT_BOOL* pbVal );
};

Data Object

This interface is implemented by Enterprise Guide. It provides access to information about the data source.

interface ISEGData : IUnknown	{
    [id(1)] HRESULT Server( [out, retval] BSTR* pbstrVal );
    [id(2)] HRESULT Libref( [out, retval] BSTR* pbstrVal );
    [id(3)] HRESULT GetConnectString( [in] long lType, [out, retval] BSTR* pbstrVal );
    [id(4)] HRESULT GetAccessor( [out, retval] ISEGAccessor** ppiAccessor );
    [id(5)] HRESULT Member( [out, retval] BSTR* pbstrVal );
    [id(6)] HRESULT File( [out, retval] BSTR* pbstrVal );
    [id(7)] HRESULT Type( [out, retval] long* plVal );
    [id(8)] HRESULT SubType( [out, retval] long* plVal );
    [id(9)] HRESULT DataSource( [out, retval] BSTR* pbstrVal );
    [id(10)] HRESULT Table( [out, retval] BSTR* pbstrVal );
};

Accessor Object

This interface is implemented by Enterprise Guide. It provides access to the data source column and value properties.
interface ISEGAccessor : IUnknown {
    [id(1)] HRESULT Columns( [out, retval] long* plCount );
    [id(2)] HRESULT Rows( [out, retval] long* plCount );
    [id(3)] HRESULT GetColumnInfoItem( [in] VARIANT varColumn,
[out, retval] ISEGColumnInfo** ppiColumnInfo );
    [id(4)] HRESULT GetRawValue( [in] VARIANT varColumn, [in] long lRow,
[out] long* plMissing,VARIANT_BOOL* pbMissing, [out, retval] VARIANT* pvarValue );
    [id(5)] HRESULT GetFormattedValue( [in] VARIANT varColumn, [in] long lRow,
[out] long* plMissing,VARIANT_BOOL* pbMissing, [out, retval] VARIANT* pvarValue );
    [id(6)] HRESULT GetColumnList( [out] SAFEARRAY(BSTR)* pbstrVariableArray );
    [id(7)] HRESULT GetColumnInfoList(
[out] SAFEARRAY(ISEGColumnInfo)* pcColumnInfoArray );
};

ColumnInfo Object

This interface is implemented by Enterprise Guide. It provides access to an individual column's properties.
interface ISEGColumnInfo : IUnknown {
    [id(1)] HRESULT VariableName( [out, retval] BSTR* pbstrVal );
    [id(2)] HRESULT VariableType( [out, retval] long* plVal );
    [id(3)] HRESULT VariableGroup( [out, retval] long* plVal );
    [id(4)] HRESULT Length( [out, retval] long* plVal );
    [id(5)] HRESULT Informat( [out, retval] BSTR* pbstrVal );
    [id(6)] HRESULT SortPosition( [out, retval] long* plVal );
    [id(7)] HRESULT SortedBy( [out, retval] long* plVal);VARIANT_BOOL* pbVal );
    [id(8)] HRESULT Indexed( [out, retval] BOOL* plVal);VARIANT_BOOL* pbVal );
    [id(9)] HRESULT MissingAllowed( [out, retval] BOOL* plVal);VARIANT_BOOL* pbVal );
    [id(10)] HRESULT Offset( [out, retval] long* plVal );
    [id(11)] HRESULT DisplayName( [out, retval] BSTR* pbstrVal );
    [id(12)] HRESULT Format( [out, retval] BSTR* pbstrVal );
};

Visual Basic Application Programming Interface

Add-In Implementation

SEGAddIn

  Connect
  Disconnect
  GetDescription
  GetName

SEGTask

  GetOptionsFlag
  GetOutputDataCount
  GetOutputDataInfo
  GetProperty
  GetPropertyList
  GetRequiresData
  GetRunLog
  GetSubmitCode
  SetProperty
  Show
  Terminate

SEGTaskInfo

  GetTaskCategory
  GetTaskDescription
  GetTaskMajorVersion
  GetTaskMinorVersion
  GetTaskName
  GetTaskProcsUsed
  GetTaskType
  GetTaskValidation

SEGSubmitSink

  SubmitComplete
  SubmitError

 SEGErrorSink

  ExecutionError

  SEGDataSink

  ActiveDataChanged
  GenerateOutputData
  GenerateOutputDataNames

Application Framework Implementation

SEGApplication

  AssignServer
  CancelSubmit
  CreateDataObject
  CreateMemberName
  GetActiveData
  GetLibraryList
  GetNextVariable
  GetOption
  GetServerList
  GetValidLiteral
  GetWorkspace
  Language
  SubmitCode

SEGData

  File
  GetAccessor
  GetConnectString
  DataSource
  Libref
  Member
  Server
  SubType
  Table
  Type

SEGColumnInfo

   DisplayName
   Format
   Indexed
   Informat
   Length
   MissingAllowed
   Offset
   SortedBy
   SortPosition
   VariableGroup
   VariableName
   VariableType

SEGAccessor

   Columns
   GetColumnInfoItem
   GetColumnInfoList
   GetColumnList
   GetFormattedValue
   GetRawValue
   Rows

Connect Method

Syntax

Sub SEGAddIn_Connect(ByVal ppiApplication As SASAIOBJLib.ISEGApplication, ByVal lCookie As Long, plSuccess As Long)

Parameters

ppiApplication
A reference to an application framework object. This object provides a set of routines for obtaining information from the application framework.
lCookie
A 32-bit unique value assigned to this task. This is for future use and can be ignored for this version.
plSuccess
A flag that tells the application framework that the connection succeeded or failed. Set this value to either APP_CONNECTION_SUCCESS or APP_CONNECTION_FAILED.

Remarks

The connect routine is used to establish an initial connection to the task. The task will need to set the plSuccess to the appropriate value to allow the application framework to continue with the task.

Example
Private Sub SEGAddIn_Connect(ByVal ppiApplication As
   SASAIOBJLib.ISEGApplication, _
ByVal lCookie As Long, plSuccess As Long)

    'Store the interface for use later in this module
    Set Application = ppiApplication

    'Allocate the memory for the form on demand
    Set Task = New MyDialog

    'Return the appropriate value to signal a successful connection
    plSuccess = APP_CONNECTION_SUCCESS

End Sub

See Also

  • Disconnect

Disconnect Method

Syntax

Sub SEGAddIn_Disconnect()

Remarks

This method is called when the instance of the task is about to be unloaded from memory, as when the task is deleted from the project collection or when the user closes the application.

Example
Private Sub SEGAddIn_Disconnect()

    Unload Task   'Clean up the allocated form

End Sub

See Also

  • Connect

GetName Method

Syntax

Sub SEGAddIn_GetName(pbstrVal As String)

Parameters

pbstrVal
The pbstrVal string is the logical name of the task.

Remarks

The pbstrVal, which is the logical name of the task, will be displayed in the add-in manager window. It is not to be confused with the display name discussed under GetTaskName Method.

Example
Private Sub SEGAddIn_GetName(pbstrVal As String)

    'The display name that references this AddIn
    pbstrVal = "MyAddIn - Visual Basic"

End Sub

See Also

  • GetDescription

GetDescription Method

Syntax

Sub SEGAddIn_GetDescription(pbstrVal As String )

Parameters

pbstrVal
The pbstrVal string is the logical description of the task.

Remarks

The pbstrVal, which is the logical description of the task, will be displayed in the add-in manager window. It is not to be confused with the task description discussed under GetTaskDescription Method.

Example
Private Sub SEGAddIn_GetDescription(pbstrVal As String)

    'The description of this AddIn
    pbstrVal = "MyAddIn - A Sample Add-In created using Visual Basic"

End Sub

See Also

  • GetName

Initialize Method

Syntax

Sub SEGTask_Initialize(plSuccess As Long)

Parameters

plSuccess
A flag that tells the application framework that the add-in succeeded or failed to initialize. Set this value to either APP_INITIALIZE_SUCCESS or APP_INITIALIZE_FAILED.

Remarks

This routine is called each time the task is invoked. Add-ins should set its controls to their default values and load any controls that display active data values from within the initialize routine. This is important because the add-in may receive subsequent SetProperty calls to reset properties to a new value which is dependent on the default values previously set. This is most obvious when using the variable selector control, and the role values also need to be assigned.

Example

Private Sub SEGTask_Initialize(plSuccess As Long)

End Sub

See Also

  • SetProperty

  • Terminate

Show Method

Syntax

Sub SEGTask_Show (ByVal lParentWindowHandle As Long, plStatus As Long)

Parameters

lParentWindowHandle
A 32-bit long value that is the task's parent window. This value can be ignored in most cases.
plStatus
As an [in] value, plStatus notifies the add-in of the last selected item in the project collection prior to invoking the add-in. Each of the values in the Settings section represents the current item selected in the project collection upon invoking the add-in. If the add-in is invoked from the context menu, then it is bit-masked with the APP_SHOW_CONTEXT_MENU value. In this release, only internally built add-ins can be invoked from the context menu.

Settings

plStatus is initially set to one of the first four values listed below.
256
APP_SHOW_PROJECT_ACTIVE

512
APP_SHOW_DATA_ACTIVE

768
APP_SHOW_TASK_ACTIVE

1024
APP_SHOW_OTHER_ACTIVE

4096
APP_SHOW_AUTOMATION

8192
APP_SHOW_CONTEXT_MENU

Upon exiting the Show method, plStatus as an [out] value must be set to one of the values listed below in order to notify Enterprise Guide of the next action to take.
0
APP_SHOW_CANCELED

1
APP_SHOW_RUNNOW

2
APP_SHOW_RUNLATER

Remarks

This routine is used to display a custom wizard. The GetSubmitCode method is called after this function and returns the generated or stored SAS code. Be sure that the code generated as a result of the Show method being called is available when the routine goes out of scope; otherwise the GetSubmitCode method may not return the correct information. In addition, if the task does not display a wizard, the routine should still set the plStatus parameter to APP_SHOW_RUNNOW to enable the application framework to continue processing the task.

Example
Private Sub SEGTask_Show(ByVal lParentWindowHandle As Long, plStatus As Long)

    Task.Show vbModal                      'Display the dialog
    plResult = APP_SHOW_CANCELED           'Initialize the status parameter
    If Task.mOkUpdate = True Then
        plStatus = APP_SHOW_RUNNOW         'Set the status to success
    End If

End Sub

See Also

  • GetSubmitCode

  • Terminate

Terminate Method

Syntax

Sub SEGTask_Terminate()

Remarks

This routine is called at the end of each task session. It signals to the add-in that it can perform any necessary post-processing cleanup.

Example

Private Sub SEGTask_Terminate()
    Unload Task   'Cleanup
End Sub

See Also

  • Initialize

GetPropertyList Method

Syntax

Sub SEGTask_GetPropertyList(pbstrKeyArray() As String)

Parameters

pbstrKeyArray
A list of keys, each representing a value that is stored and reloaded to and from the project file. The pbstrKeyArray is in the form of a SAFEARRAY(BSTR), which represents an array of string values.

Remarks

This routine is called each time the task is saved to a project file and loaded from a project file. The keys must be unique. They are not required to be in any specific order.

Example
Private Sub SEGTask_GetPropertyList(pbstrKeyArray() As String)

ReDim pbstrKeyArray(2) As String
   pbstrKeyArray(0) = "SERVER"
   pbstrKeyArray(1) = "CODE"

End Sub

See Also

  • GetProperty

  • SetProperty

GetProperty Method

Syntax

Sub SEGTask_GetProperty(ByVal bstrKey As String, pbstrVal As String)

Parameters

bstrKey
A unique key that represents a value to be stored in the project file. The key is part of the list returned in the GetPropertyList method.
pbstrVal
The actual value to be stored in the project file. All values are stored as string values and will need to be converted where appropriate.

Remarks

This routine is used to save the state information specific to the task in the project file. It is called when the user saves the project and the project contains a custom task. If the add-in returns an empty property list, then the GetProperty method is not called.

Example
Private Sub SEGTask_GetProperty(ByVal bstrKey As String, pbstrVal As String)

    If bstrKey = "SERVER" Then
        pbstrVal = Task.Server
    End If

    If bstrKey = "CODE" Then
        pbstrVal = Task.Code
    End If

End Sub

See Also

  • GetPropertyList

  • SetProperty

SetProperty Method

Syntax

Sub SEGTask_SetProperty ByVal bstrKey As String, ByVal bstrVal As String)

Parameters

bstrKey
A unique key that represents a value to be retrieved from the project file. The key is part of the list returned in the GetPropertyList method.
bstrVal
The actual value to be retrieved from the project file. All values are stored as string values and will need to be converted where appropriate.

Remarks

This routine is used to get the state information specific to the custom task in the project file. It is called when the user loads a project and the project contains a custom task. If the task returns an empty property list, then the SetProperty method is not called.

Example
Private Sub SEGTask_SetProperty(ByVal bstrKey As String, ByVal bstrVal As String)

    If bstrKey = "SERVER" Then
        If bstrVal <> "" Then
            Task.Server = bstrVal
        End If
    End If

    If bstrKey = "CODE" Then
        If bstrVal <> "" Then
            Task.Code = bstrVal
        End If
    End If

End Sub

GetSubmitCode Method

Syntax

Sub SEGTask_GetSubmitCode(pbstrVal As String)

Parameters

pbstrVal
This is the SAS code the custom task generates. It is submitted to a SAS session to be processed.

Remarks

This routine is called from the application framework to get the generated or stored SAS code. The GetSubmitCode method may be called without a prior call to the Show method. Therefore it is important to perform the SAS code generation from this routine or another that is called from the GetSubmitCode method and not from any other method.

Example
Private Sub SEGTask_GetSubmitCode(pbstrCode As String)

  pbstrCode = Task.Code  'Code is a function in the form that generates the SAS code

End Sub

See Also

  • Show

  • GenerateOutputDataNames

GetRunLog Method

Syntax

Sub SEGTask_GetRunLog(pbstrVal As String)

Parameters

pbstrVal
The pbstrVal string provides a way for the task to return a run log or status when not generating SAS code.

Remarks

This routine is used in the event that the task does not return any SAS code when the GetSubmitCode method is called. The run log represents processing that may have occurred from within the task. Most tasks will return SAS code to be processed where a log is created, displaying the processing results in the project collection tree. In the event that there is no SAS code to process, the pbstrVal string is displayed as the log.

Example
Private Sub SEGTask_GetRunLog(pbstrVal As String)

   pbstrVal = "Generated data sets:  test1.sas7bdat, test2.sas7bdat"

End Sub

GetOptionsFlag Method

Syntax

Sub SEGTask_GetOptionsFlag(plOptions As Long)

Parameters

plOptions
A 32-bit value that allows the custom task to be associated with a predefined category.

Settings

APP_TASK_CATEGORY values 1-12 allow the add-in to merge into a predefined category. These predefined categories are defined as Tools, Data, Graph, or one of the items in the Analysis menu. If the add-in includes any of the values in the range 1-12, then the value returned in the GetTaskCategory method is ignored. The available predefined categories for the add-in may be merged with include values 1-12.
0
APP_TASK_CATEGORY_USER_DEFINED

1
APP_TASK_CATEGORY_GRAPH

2
APP_TASK_CATEGORY_TOOLS

3
APP_TASK_CATEGORY_DATA

4
APP_TASK_CATEGORY_DESCRIPTIVE

5
APP_TASK_CATEGORY_ANOVA

6
APP_TASK_CATEGORY_REGRESSION

7
APP_TASK_CATEGORY_MULTIVARIATE

8
APP_TASK_CATEGORY_SURVIVAL_ANALYSIS

9
APP_TASK_CATEGORY_CONTROL_CHARTS

10
APP_TASK_CATEGORY_TIME_SERIES

11
APP_TASK_CATEGORY_PARETO_CHART

12
APP_TASK_CATEGORY_TABLE_ANALYSIS

1024
APP_TASK_CUSTOMIZE_NOT_REMOVABLE

Remarks

This method allows a custom task to return some bit-mask attributes about the add-in. To block an add-in's removal from the list of available add-ins in the Customize window, include the APP_TASK_CUSTOMIZE_NOT_REMOVABLE attribute in the bit-mask value.

Example
Private Sub SEGTask_GetOptionsFlag(plOptions As Long)
    plOptions = APP_TASK_CATEGORY_USER_DEFINED
End Sub

GetRequiresData Method

Syntax

Sub SEGTask_GetRequiresData(plVal As Long)

Parameters

plVal
A flag that tells the application framework that the task requires input data. Set plVal to APP_DATAOPTION_REQUIRED if the task requires input data. Otherwise, set plVal to APP_DATAOPTION_NONE.

Settings

The APP_DATAOPTION_OPTIONAL tells the application framework that input data is not required but that if there is an active data source in the project collection, the data can be retrieved through the GetActiveData method. If the add-in returns APP_DATAOPTION_NONE, the GetActiveData method does not return a valid data object. The APP_DATAOPTION_ROOT is a bit-mask value and is used to notify the application framework that the task should always be parented to the project root and not the active data.

0
APP_DATAOPTION_NONE

1
APP_DATAOPTION_REQUIRED

2
APP_DATAOPTION_OPTIONAL

256
APP_DATAOPTION_ROOT

Remarks

This routine allows the application framework to take appropriate actions, such as displaying a file selection dialog if there is no active data currently in the project. Once there is data in the project, the task can use the GetActiveData method to get an active data object.

Example

Private Sub SEGTask_GetRequiresData(plVal As Long)
    plVal = APP_DATAOPTION_REQUIRED
End Sub

GetOutputDataCount Method

Syntax

Sub SEGTask_GetOutputDataCount(plCount As Long)

Parameters

plCount
Represents the number of output data sources to be loaded into the project tree and associated with the task. Set plCount to zero if you do not want any output data added to the project collection. You may also set plCount to -1, which automatically loads all the generated output data sets that are a result of submitted SAS code into the project tree.

Remarks

This routine is called in conjunction with the GetOutputDataInfo method. When GetOutputDataCount is set to 0 or -1, the add-in does not receive a subsequent GetOutputDataInfo.

Example

Private Sub SEGTask_GetOutputDataCount(plCount As Long)
    plCount = 2	'GetOutputDataInfo will be called two times
End Sub

See Also

  • GetOutputDataInfo

GetOutputDataInfo Method

Syntax

Sub SEGTask_GetOutputDataInfo(ByVal lIndex As Long, pbstrSource As String, pbstrLabel As String, plFile As Long)

Parameters

lIndex
The zero-based index of the output data information.
pbstrSource
The string that represents the output data. The pbstrSource represents a fully qualified SAS data set (<library>.<data set>), a local file system name (<drive>|<unc>\<directory>\<file name>), or a SAS Directory Services naming convention.
pbstrLabel
The display name for the output data in the project tree.
plFile
The type of data source name in the pbstrSource parameter. If plFile is equal to APP_OUTPUT_LIBREF, then pbstrSource (<library>.<data set>) should be used. If the plFile parameter is equal to APP_OUTPUT_FILEPATH, then pbstrSource (<drive>|<unc>\<directory>\<file name>) should be used. Finally, if plFile is equal to APP_OUTPUT_SDSNAME, then a SAS Directory Services naming convention source should be used.

Remarks

This routine is called only if the GetOutputDataCount routine returns a plCount value greater than zero. GetOutputDataInfo is called for each index from 0 to n-1, where n is the plCount value returned when the GetOutputDataCount method is called. This gives the developer a means of adding additional data sources to the task item in the project tree. The APP_OUTPUT_FILEPATH source is not limited to SAS data sets. pbstrSource could point to a comma-delimited text file or an Excel file.

Example
Private Sub SEGTask_GetOutputDataInfo(ByVal lIndex As Long, _
pbstrSource As String, pbstrLabel As String, plFile As Long)

If (lIndex = 0) Then
   pbstrSource = "C:\Work\Data\Test1.sas7bdat"
   plFile = APP_OUTPUT_FILEPATH
End If

If (lIndex = 1) Then
   pbstrSource = "WORK.TEST2"
   plFile = APP_OUTPUT_LIBREF
End If

End Sub

See Also

  • GetOutputDataCount

GetTaskCategory Method

Syntax

Sub SEGTaskInfo_GetTaskCategory(pbstrVal As String)

Parameters

pbstrVal
pbstrVal represents the category the task is assigned when displayed in the Task list and the main menu.

Remarks

This string should be the same for similar tasks - for example, Real Estate, Reports, Consumer, and Custom. If there is more than one task assigned to a category, a submenu is created in the main menu and it has the same label as the category. In the Tasks by Category, the list of grouped tasks are organized under the assigned category. Most categories are grouped under the Analysis menu item.

If the GetOptionFlag method returns a value other than APP_TASK_CATEGORY_USER_DEFINED, this value is ignored.

Example
Private Sub SEGTaskInfo_GetTaskCategory(pbstrVal As String)

pbstrVal = "Custom"

End Sub

See Also

  • GetOptionsFlag

GetTaskDescription Method

Syntax

Sub SEGTaskInfo_GetTaskDescription(pbstrVal As String)

Parameters

pbstrVal
The pbstrVal is a short description of the task.

Remarks

Use this value to assign a short description to the task to help explain its usage. This value is for display purpose only. Currently, this value is not used in the Enterprise Guide framework.

Example
Private Sub SEGTaskInfo_GetTaskDescription(pbstrVal As String)

pbstrVal = "Calls PROC MEANS to do simple analysis on the CRIME data set"

End Sub

See Also

  • GetTaskName

  • GetDescription

GetTaskMajorVersion Method

Syntax

Sub SEGTaskInfo_GetTaskMajorVersion(plVal As Long)

Parameters

plVal
Represents the major version of the custom task.

Remarks

Use the value to assign a major version value to the release of the custom task. This value is combined with the GetTaskMinorVersion value and then displayed in the Task by Name window in the Version column located in the Task List. This value is for display purposes only.

Example
Private Sub SEGTaskInfo_GetTaskMajorVersion(plVal As Long)

plVal = 1

End Sub

See Also

  • GetTaskMinorVersion

GetTaskMinorVersion Method

Syntax

Sub SEGTaskInfo_GetTaskMinorVersion(plVal As Long)

Parameters

plVal
Represents the minor version of the custom task.

Remarks

Use the value to assign a minor version value to the release of the custom task. This value is appended to the GetTaskMajorVersion value and then displayed in the Task by Name window in the Version column located in the Task List. This value is for display purposes only.

Example
Private Sub SEGTaskInfo_GetTaskMinorVersion(plVal As Long)

plVal = 0

End Sub

See Also

  • GetTaskMajorVersion

GetTaskName Method
Syntax

Sub SEGTaskInfo_GetTaskName(pbstrVal As String)

Parameters

pbstrVal
Represents the display name of the task in the task list.

Remarks

This value represents the name that the add-in assigns to the custom task. It is added to the normal task list and the menu to allow access to the extended functionality.

Example
Private Sub SEGTaskInfo_GetTaskName(pbstrVal As String)

   pbstrVal = "My Summary Statistics"

End Sub

See Also

  • GetName

GetTaskType Method

Syntax

Sub SEGTaskInfo_GetTaskType(plVal As Long)

Parameters

plVal
If plVal is set to APP_TASKTYPE_WIZARD, then the task is a wizard (custom task). If plVal is set to APP_TASKTYPE_CODE, then the task is a library (code task).

Remarks

The GetTaskType routine allows the application framework to determine the task creation behavior. The task is represented in the project tree as either a dialog-based task or a code window task.

Example
Private Sub SEGTaskInfo_GetTaskType(plType As Long)

   plType = APP_TASKTYPE_WIZARD

End Sub

GetTaskProcsUsed Method
Syntax

Sub SEGTaskInfo_GetTaskProcsUsed(pbstrVal As String)

Parameters

pbstrVal
A string that represents the SAS procedures that are used in the SAS code generated by the task. This value may be an empty string.

Remarks

This routine is called from the application framework to retrieve a delimited list of SAS procedures used in the SAS code. The form of the string should be delimited with a semicolon - for example, GPLOT;G3D - for each procedure. This value is displayed in the Task by Name window in the SAS Procedures column located in the Task List. This value is for display purpose only.

Example
Private Sub SEGTaskInfo_GetTaskProcsUsed(pbstrVal As String)

   pbstrVal = "MEANS;PRINT" 'Use ; as a delimiter

End Sub

GetTaskValidation Method
Syntax

Sub SEGTaskInfo_GetTaskValidation(pbstrVal As String)

Parameters

pbstrVal
A string that represents the optional validation string that is defined by the add-in.

Remarks

The routine is called from the application framework to retrieve a validation string. This value can represent a validation code or a certificate string. It is an optional value provided by the author. This value is displayed in the Task by Name window in the Validation column located in the Task List.

Example
Private Sub SEGTaskInfo_GetTaskValidation(pbstrVal As String)

   pbstrVal = "XYZ Certified"

End Sub

SubmitComplete Method
Syntax

Sub SEGSubmitSink_SubmitComplete (ByVal lSubmitCookie As Long, ByVal lSuccess As Long)

Parameters

lSubmitCookie
A 32-bit unique value that represents the submitted SAS code session.
lSuccess
A flag that represents the results for SAS code being processed. The value 1 equals success and the value 0 equals failure.

Remarks

This routine is always called after an intermediate code submit is made. It is used in conjunction with the SubmitCode method. The CancelSubmit method forces a SubmitCode to be cancelled, thus this routine would never be called for the specific submit cookie. To implement this method, include Implements SEGSubmitSink.

Example
Private Sub SEGSubmitSink_SubmitComplete(ByVal lSubmitCookie As Long, ByVal lSuccess As Long)
   'Display the results of the intermediate code submit
   If (lSuccess = 1) Then
      MsgBox Task.Properties
   End If
End Sub

See Also

  • SubmitCode

  • CancelSubmit

SubmitError Method
Syntax

Sub SEGSubmitSink_SubmitError (ByVal lSubmitCookie As Long, ByVal lErrorCode As Long, ByVal bstrErrorString As String)

Parameters

lSubmitCookie
A 32-bit unique value that represents thsubmitteded SAS code session.
lErrorCode
An error code value that references the problem.
bstrErrorString
A short description of the error that occurred.

Remarks

This routine is called if a problem occurs while an intermediate code submit is used. It is used in conjunction with the SubmitCode method and is only called when an error occurs. To implement this method, include Implements SEGSubmitSink.

Example
Private Sub SEGSubmitSink_SubmitError(ByVal lSubmitCookie As Long, ByVal lErrorCode As Long, _
ByVal bstrErrorString As String)
   MsgBox "SubmitError Has Occurred" & vbCrLf & vbCrLf & _
      "Identifier : " & CStr(lSubmitCookie) & vbCrLf & _
      "Error Code : " & CStr(lErrorCode) & vbCrLf & vbCrLf & _
      bstrErrorString & vbCrLf
End Sub

See Also

  • SubmitCode

  • CancelSubmit

ExecutionError Method
Syntax

Sub SEGErrorSink_ExecutionError (ByVal lErrorCode As Long, ByVal bstrDescription As String, ByVal bstrProgID As String, ByVal bstrMethod As String, ByVal bstrParameter As String)

Parameters

lErrorCode
An error code value that references the problem.
bstrDescription
A short description of the error that occurred.
bstrProgID
The program identifier for the registered object.
bstrMethod
The name of the custom task method in which the error occurred.
bstrParameter
The name of the custom task parameter that caused the error.

Settings

The error code can be one of the following values listed below and will be within the range between APP_ERROR_BASE and APP_ERROR_LAST.

69633
APP_ERROR_FAIL

69634
APP_ERROR_INVALID_PARAM

69635
APP_ERROR_INVALID_POINTER

69636
APP_ERROR_INVALID_STRING

69637
APP_ERROR_INVALID_SOURCE

69638
APP_ERROR_NOT_SUPPORTED

69639
APP_ERROR_NOT_FOUND

Remarks

This routine is called if a problem occurred while the task was executing. It is used to process error messages and debug code while developing custom tasks. To implement this method, include Implements SEGErrorSink.

Example
Private Sub SEGErrorSink_ExecutionError(ByVal lErrorCode As Long, ByVal bstrDescription As String, ByVal bstrProgID As String, ByVal bstrMethod As String, ByVal bstrParameter As String)

       MsgBox "An Error " & CStr(lErrorCode) & occurreded with the " & bstrProgID & _
        "Task while calling" & vbCrLf & "the method """ & bstrMethod & _
        """ and attempting to use the parameter """ & bstrParameter & """."
 """." & _

   vbCrLf & bstrDescription, vbCritical, "AddIn Error"

   MsgBox ErrorText, vbCritical, "AddIn Error"
End Sub

ActiveDataChanged Method

Syntax

Sub SEGDataSink_ActiveDataChanged()

Remarks

This routine is called to notify the add-in that the active data has changed. The ActiveDataChanged method is called the very first time an add-in is invoked. If the add-in is invoked again, the ActiveDataChanged method is only called if the data associated with the task has changed.

Example

Private Sub SEGDataSink_ActiveDataChanged()
    Task.Data = Application.GetActiveData
End Sub

ActiveDataChanged Method

Syntax

Sub SEGDataSink_ActiveDataChanged()

Remarks

This routine is called to notify the add-in that the active data has changed. The ActiveDataChanged method is called the very first time an add-in is invoked. If the add-in is invoked again, the ActiveDataChanged method is only called if the data associated with the task has changed.

Example

Private Sub SEGDataSink_ActiveDataChanged()
    Task.Data = Application.GetActiveData
End Sub

GenerateOutputData Method

Syntax

Sub SEGDataSink_GenerateOutputData(plSuccess As Long)

Parameters

plSuccess
A flag that tells the application framework that the add-in succeeded or failed. Set this value to either APP_GENERATEDDATA_SUCCESS or APP_GENERATEDDATA_FAILED.

Remarks

This routine is called to notify the add-in that it can generate output data. In most cases the add-in does not need to generate its own output data results, provided it is generating SAS code for processing. In the event the add-in does not use SAS code to generate output data, the GenerateOutputData method is the proper place to create the data. The GetOutputDataInfo method is called immediately after this method. If the GenerateOutputData method returns APP_GENERATEDDATA_FAILED, then the GetOutputDataInfo method is not called.

Example

Private Sub SEGDataSink_GenerateOutputData(plSuccess As Long)
    'Generate some output data for the GetOutputDataInfo method
    plSuccess = APP_GENERATEDDATA_SUCCESS
End Sub

See Also

  • GetOutputDataInfo

GenerateOutputDataNames Method

Syntax

Sub SEGDataSink_GenerateOutputDataNames()

Remarks

This method is called to notify the add-in that it needs to generate new unique output data names. The GenerateOutputDataNames method is only called when the task is invoked a second time and the user chooses not to replace results.

Example

Private Sub SEGDataSink_GenerateOutputDataNames()
    Task.OutputMember = Application.CreateMemberName _
    Task.OutputServer, Task.OutputLibref, "ADDIN"
End Sub

See Also

  • GenerateOutputData

AssignServer Method

Syntax

object.AssignServer server

Parameters

server
The logical name of a SAS server.

Return Values

The AssignServer method returns a Boolean value notifying the add-in of the success of the server assignment.

Remarks

By default, SAS code is submitted to the same server on which the active data resides. Use this method to change the server to which the SAS code is submitted. This is especially important in cases where SAS code does not rely on a data source.

Member of SASAIOBJLib.SEGApplication

Example

Private Sub SEGTask_Show(ByVal lParentWindowHandle As Long, plStatus As Long)
    Task.Show vbModal                           	'Display the dialog
    plResult = APP_SHOW_CANCELED      	'Initialize the status parameter
    If Task.mOkUpdate = True Then
        Application.AssignServer Task.Server
        plStatus = APP_SHOW_RUNNOW    	'Set the status to success
    End If
End Sub

GetActiveData Method
Syntax

object.GetActiveData

Return Values

Returns a SEGData object for the active data.

Remarks

This routine is used to get a data object from the application framework. This object represents the active data source associated with the task.

Member of SASAIOBJLib.SEGApplication

Example
Public Application As SEGApplication
Private Data As SEGData
.
.
.

Private Sub Form_Load
   ' Get the input data from the framework
   Data = Application.GetActiveData()
End Sub

GetServerList Method
Syntax

object.GetServerList serverarray

Parameters

serverarray
Receives a list of SAS server names. This list represents the defined list of SAS servers as they are defined in the repository. The serverarray is in the form of a SAFEARRAY(BSTR), which represents an array of string values.

Remarks

This routine returns a list of SAS servers that have been previously defined using the Enterprise Guide Administrator. This is the same server list used throughout Enterprise Guide.

Member of SASAIOBJLib.SEGApplication

Example
Dim ServerArray() As String
Dim Index As Long
Dim Count As Long

Application.GetServerList ServerArray()

Index = Lbound(ServerArray)
Count = Ubound(ServerArray)

Do While Index < Count
.
.
.
Loop

See Also

  • GetLibraryList

GetLibraryList Method
Syntax

object.GetLibraryList(Server, libraryarray)

Parameters

server
The logical name of a SAS server.
libraryarray
Receives a list of SAS library names associated with the SAS Server. The libraryarray is in the form of a SAFEARRAY(BSTR), which represents an array of string values.

Remarks

Use this routine to obtain a list of SAS libraries for a specific SAS server.

Member of SASAIOBJLib.SEGApplication

Example
Dim LibraryArray() As String
Dim Index As Long
Dim Count As Long

Application.GetLibraryList "Local", LibraryArray()

Index = Lbound(LibraryArray)
Count = Ubound(LibraryArray)

Do While Index < Count
.
.
.
Loop

See Also

  • GetServerList

GetWorkspace Method
Syntax

object.GetWorkspace server

Parameters

server
The logical name of a SAS server.

Return Values

Returns the SAS Workspace object. This object accesses the SAS Integration Technologies core set of interfaces.

Remarks

This routine surfaces the same SAS workspace object SAS Enterprise Guide uses. More information about the Workspace object can be found in the SAS Integration Technologies online documentation at http://www.sas.com/rnd/itech. To use the Workspace object, you will need to reference the SAS Integrated Object Model (IOM) 1.0 Type Library.

Member of SASAIOBJLib.SEGApplication

Example
Dim MyWorkspace As Workspace

Set MyWorkspace = Application.GetWorkspace("Local")
MsgBox MyWorkspace.UniqueIdentifier

SubmitCode Method
Syntax

object.SubmitCode code, server, async

Parameters

code
The actual SAS code that is to be processed.
server
The logical name of the SAS server where the SAS code is to be processed.
sync
An option flag to allow the intermediate step to run in asynchronous or synchronous mode. Use 1 for asynchronous mode and 0 for synchronous mode. Currently, only asynchronous mode is supported.

Return Values

Returns a 32-bit unique value that represents the submitted SAS code session.

Remarks

This routine allows the developer to perform intermediate code submits to SAS within the scope of the task. Use this routine handle additional processing from within the task.

Member of SASAIOBJLib.SEGApplication

Example
Dim SubmitCode As String
Dim SubmitCookie As Long

'Temporarily insert a library definition to the submitted code
SubmitCode = SubmitCode & "LIBNAME ECLIB001 ""C:\Sample\Data""; " & vbCrLf
SubmitCode = SubmitCode & Code

'Intermediate code submit to test the submit code feature
SubmitCookie  = Application.SubmitCode(SubmitCode, "Local", 1)

See Also

  • CancelSubmit

  • SubmitComplete

  • SubmitError

CancelSubmit Method
Syntax

object.CancelSubmit lSubmitCookie

Parameters

submitcookie
A 32-bit unique value that represents previously submitted SAS code session.

Remarks

This routine can be called from within the task code to cancel an intermediate code submit. This function is used in conjunction with the SubmitCode method.

Member of SASAIOBJLib.SEGApplication

Example
Public Application As SEGApplication
Private SubmitCookie As Long
.
.
.
Private Sub CancelButton_Click()
   If SubmitCookie <> 0 Then
      Application.CancelSubmit SubmitCookie
   End if

   OkSelected = False
   Hide
End Sub

See Also

  • SubmitCode

Language Property
Syntax

object.Language

Remarks

This routine allows the developer to determine which language is being used by Enterprise Guide to display text. This routine is normally used prior to displaying any dialog or wizard to determine the correct locale.

Member of SASAIOBJLib.SEGApplication

Example
Private Sub Form_Load
   Dim LCID As Long

   'Get the LCID value from the framework
   Lcid = Application.Language
   If LCID = 1033 Then
      MsgBox "Localization  = English"
   End If
End Sub

GetOption Method
Syntax

object.GetOption optioncode

Parameters

optionCode
An application framework option code that represents the value to retrieve.

Settings

optioncode can have these values:

1
APP_OPTION_DOCLOC

2
APP_OPTION_SYSTEMLOC

3
APP_OPTION_USERLOC

6
APP_OPTION_DISPLAY_COLUMN_ALPHA_ORDER

7
APP_OPTION_SHOW_COLUMN_LABEL

8
APP_OPTION_LASTDATAFOLDER

9
APP_OPTION_LASTDATAFILTER

10
APP_OPTION_SORTPERFORMANCETHRESHOLD

11
APP_OPTION_ENABLEACCESSIBLITYFEATURES

12
APP_OPTION_RUNAUTOMATIONMODE

13
APP_OPTION_DEFAULTSASSERVER

114
APP_OPTION_INCLUDEDATASCHEMA

115
APP_OPTION_EXCELAUTOWDTH

116
APP_OPTION_EXCELAUTONAME

117
APP_OPTION_IMPORTLOOKAHEADROWS

Return Values

Returns the actual application framework value as a variant type.

Remarks

This is an advanced function used to retrieve a small list of surfaced option settings.

Member of SASAIOBJLib.SEGApplication

Example
Dim Value As Long

Value  = Application.GetOption(APP_OPTION_SHOW_COLUMN_LABEL)
VariableSelector_V21.SetShowLabels Value

GetValidLiteral Method
Syntax

object.GetValidLiteral value

Parameters

value
The SAS variable to convert.

Return Values

Returns a valid SAS variable with double or single quotes if they are required.

Remarks

Member of SASAIOBJLib.SEGApplication

Example
Function RoleValues(ByVal strRole) As String
   Dim Variable As String
   Dim Count As Long
   Dim Index As Long
   Dim lResult As Long

   Count = VariableSelector_V21.GetNumberAssignedVars(strRole)
   Index = 0
   While Index < Count
      Variable  = Application.GetValidLiteral(VariableSelector_V21.GetAssignedVar(strRole, Index))
   RoleValues = RoleValues + Variable
   Index = Index + 1
      If Index < Count Then
         RoleValues = RoleValues + " "
      End If
   Wend
End Function

See Also

  • GetNextVariable

GetNextVariable Method
Syntax

object.GetNextVariable source, modified

Parameters

source
The input buffer to parse.
modified
Receives the new output buffer.

Return Values

Returns the next variable from a literal delimited buffer.

Remarks

Use this routine to walk through a buffer of variables.

Member of SASAIOBJLib.SEGApplication

Example
Function AssignRoleValues(ByVal strRole, ByVal strValue)
   Dim Variable As String
   Dim InBuffer As String
   Dim OutBuffer As String

   InBuffer = strValue
   Do
      'Iterate through the delimited string
      Variable  = Application.GetNextVariable(InBuffer, OutBuffer)
      VariableSelector_V21.AssignVariable Variable, strRole
      InBuffer = OutBuffer
   Loop Until Variable = ""
End Function

See Also

  • GetValidLiteral

CreateMemberName Method
Syntax

object.CreateMemberName server, libref, root

Parameters

server
The repository server name.
libref
A library name for the specified server.
root
A value to append the unique value to, for example, MEAN, TASK, or GRAPH.

Return Values

Returns a new member name unique to the specific server and library.

Remarks

Use this routine to generate a unique member name for creating output data sets. The method allows you to specify a root string so that the unique name can start with the same root value. You should use a root name of four characters or less.

Member of SASAIOBJLib.SEGApplication

Example
Private UniqueMember As String
.
.
.

If UniqueMember = "" Then
   UniqueMember  = Application.CreateMemberName("Local", "WORK", "MEAN")
End If

CreateDataObject Method
Syntax

object.CreateDataObject server, libref, member, provider

Parameters

server
The repository server name.
libref
A library name for the specified server.
member
A data set name contained within the specified library.
provider
Reserved for future use.

Return Values

Returns a SEGData object for the specified server, library, and member name.

Remarks

Member of SASAIOBJLib.SEGApplication

Example
Dim MyData As SEGData

If UniqueMember <> "" Then
   Set MyData = Application.CreateDataObject("Local", "SASHELP", " CLASS", "")
    .
    .
    .
End If

Libref Property
Syntax

object.Libref

Remarks

Use this routine to get the name of the library where the data set is located, for example, SASHELP.

Member of SASAIOBJLib.SEGData

Example
Dim Code As String
.
.
.
Code = Code & "PROC MEANS DATA=" & Data.Libref & "." & Data.Member

See Also

  • Member

  • Server

Server Property
Syntax

object.Server

Remarks

Use this routine to get the name of the server on which the data resides, for example, "Local."

Member of SASAIOBJLib.SEGData

Example
Dim UniqueMember As String
.
.
.
UniqueMember  = Application.CreateMemberName(Data.Server, "SASUSER", "MEANS")

See Also

  • Libref

GetConnectString Method
Syntax

object.GetConnectString type

Parameters

type
The type of connection that the add-in expects to make. Use 0 for ODBC and 1 for OLEDB.

Return Values

Returns the connection string for the specified provider.

Remarks

Use this value to retrieve a connection string to the data for accessing data values. This method displays a provider selection dialog box, and allows you to specify a provider to retrieve a connection string.

Member of SASAIOBJLib.SEGData

Example
Dim Value As String

Value = Data.GetConnectString(0)
MsgBox Value

GetAccessor Method
Syntax

object.GetAccessor

Return Values

Returns a SEGAccessor object for accessing the data.

Remarks

Member of SASAIOBJLib.SEGData

Example
Dim Accessor As SEGAccessor
Dim Data As SEGData

Set Data = Application.GetActiveData()
Set Accessor = Data.GetAccessor()
MsgBox "Total Columns = " & CStr(Accessor.Columns)

Member Property
Syntax

object.Member

Remarks

The name of the data set in the library associated with the SEGData object. When the data source is not a SAS data set, a temporary member name is used. The actual name of the data source can be obtained by using the Table property.

Member of SASAIOBJLib.SEGData

Example
MsgBox Data.Member

See Also

  • Libref

  • Server

  • Table

File Property
Syntax

object.File

Remarks

Use this routine to get the location of the data set. If the SEGData object references data locally, then the actual file system path is included. If the SEGData object references data from a library, then the location is in the form of Library.Member. This value is typically used when creating code headers.

Member of SASAIOBJLib.SEGData

Example
MsgBox Data.File

Table Property
Syntax

object.Table

Remarks

This is the actual name of the data source associated with the SEGData object.

Member of SASAIOBJLib.SEGData

Example
MsgBox Data.Table

See Also

  • Libref

  • Member

  • Server

DataSource Property

Syntax

object.DataSource

Remarks

Use this property to get the location of the data set. If the SEGData object references data locally, then the actual file system path is included. If the SEGData object references data from a source other than a local file, then the location is in the form of a SAS Directory Services path. This is the actual data source path returned from the Insert Data dialog when data is inserted into the project collection.

Member of SASAIOBJLib.SEGData

Example

MsgBox Data.DataSource

Type Property

Syntax

object.Type

Parameters

Settings

The Type property can be one of the following values:

0
APP_DATASOURCE_UNKNOWN

1
APP_DATASOURCE_SAS

2
APP_DATASOURCE_ADO

3
APP_DATASOURCE_ODBC

4
APP_DATASOURCE_OLEDB

6
APP_DATASOURCE_MDDB

Remarks

Use this property to get the type of data.

Member of SASAIOBJLib.SEGData

Example

If Data.Type = 1APP_DATASOURCE_OLEDB Then
    ' Perform some action
End If

SubType Property

Syntax

object.SubType

Settings

The SubType property can be one of the following values:

0
APP_SUBTYPE_UNKNOWN

1
APP_SUBTYPE_SASDATASET

2
APP_SUBTYPE_SASQUERY

3
APP_SUBTYPE_EXCELSPREADSHEET

4
APP_SUBTYPE_EXCELQUERY

5
APP_SUBTYPE_ACCESSTABLE

6
APP_SUBTYPE_ACCESSQUERY

7
APP_SUBTYPE_LOTUSSPREADSHEET

8
APP_SUBTYPE_DBASETABLE

9
APP_SUBTYPE_ADOTABLE

10
APP_SUBTYPE_ODBCDATA

11
APP_SUBTYPE_PARADOXTABLE

12
APP_SUBTYPE_TEXTTABLE

13
APP_SUBTYPE_HTMLTABLE

14
APP_SUBTYPE_EXCHANGETABLE

15
APP_SUBTYPE_OLEDBTABLE

17
APP_SUBTYPE_MDDBCUBE

Remarks

Use this property to get more detailed information about the data type.

Member of SASAIOBJLib.SEGData

Example

If Data.SubType = APP_SUBTYPE_EXCELSPREADSHEET Then
    'Perform some action
End If

VariableName Property
Syntax

object.VariableName

Remarks

A string value specifying the name of the variable.

Member of SASAIOBJLib.SEGColumnInfo

Example
Dim ColumnInfo As SEGColumnInfo

Set ColumnInfo = Accessor.GetColumnInfoItem(1)
MsgBox ColumnInfo.VariableName

VariableType Property
Syntax

object.VariableType

Settings

The VariableType property can be one of the following values:

0
APP_VARTYPE_EMPTY

1
APP_VARTYPE_NULL

2
APP_VARTYPE_I2

3
APP_VARTYPE_I4

4
APP_VARTYPE_R4

5
APP_VARTYPE_R8

6
APP_VARTYPE_CY

7
APP_VARTYPE_DATE

8
APP_VARTYPE_BSTR

9
APP_VARTYPE_IDISPATCH

10
APP_VARTYPE_ERROR

11
APP_VARTYPE_BOOL

12
APP_VARTYPE_VARIANT

13
APP_VARTYPE_IUNKNOWN

14
APP_VARTYPE_DECIMAL

16
APP_VARTYPE_I1

17
APP_VARTYPE_UI1

18
APP_VARTYPE_UI2

19
APP_VARTYPE_UI4

20
APP_VARTYPE_I8

21
APP_VARTYPE_UI8

64
APP_VARTYPE_FILETIME

72
APP_VARTYPE_GUID

128
APP_VARTYPE_BYTES

129
APP_VARTYPE_STR

130
APP_VARTYPE_WSTR

131
APP_VARTYPE_NUMERIC

132
APP_VARTYPE_UDT

133
APP_VARTYPE_DBDATE

134
APP_VARTYPE_DBTIME

135
APP_VARTYPE_DBTIMESTAMP

136
APP_VARTYPE_HCHAPTER

138
APP_VARTYPE_PROPVARIANT

139
APP_VARTYPE_VARNUMERIC

4096
APP_VARTYPE_VECTOR

8192
APP_VARTYPE_ARRAY

16384
APP_VARTYPE_BYREF

32768
APP_VARTYPE_RESERVED
Remarks

Use this property to get a value that specifies the OLEDB variable type.

Member of SASAIOBJLib.SEGColumnInfo

Example
Dim ColumnInfo As SEGColumnInfo

Set ColumnInfo = Accessor.GetColumnInfoItem(1)
If ColumnInfo.VariableType = APP_VARTYPE_R4 Then
    'Perform some action
End If

See Also

  • VariableGroup

VariableGroup Property
Syntax

object.VariableGroup

Settings

The VariableGroup property can be one of the following values:
0
APP_VARGROUP_UNKNOWN

5
APP_VARGROUP_NUMERIC

8
APP_VARGROUP_CHARACTER

9
APP_VARGROUP_DATE

10
APP_VARGROUP_TIME

11
APP_VARGROUP_CURRENCY

12
APP_VARGROUP_OTHER

13
APP_VARGROUP_OLEDATA

14
APP_VARGROUP_GEOREF

Remarks

Use this property to get a value that specifies the SAS variable group.

Member of SASAIOBJLib.SEGColumnInfo

Example
Dim ColumnInfo As SEGColumnInfo

Set ColumnInfo = Accessor.GetColumnInfoItem(1)
MsgBox ColumnInfo.VariableGroup

See Also

  • VariableType

Length Property
Syntax

object.Length

Remarks

Use this routine to get the length of the variable.

Member of SASAIOBJLib.SEGColumnInfo

Example
Dim ColumnInfo As SEGColumnInfo

Set ColumnInfo = Accessor.GetColumnInfoItem(1)
MsgBox ColumnInfo.Length

Informat Property
Syntax

object.Informat

Remarks

Use this routine to get the SAS Informat value.

Member of SASAIOBJLib.SEGColumnInfo

Example
Dim ColumnInfo As SEGColumnInfo

Set ColumnInfo = Accessor.GetColumnInfoItem(1)
MsgBox ColumnInfo.Informat

SortPosition Property
Syntax

object.SortPosition

Remarks

Use this routine to get the variable sorted position.

Member of SASAIOBJLib.SEGColumnInfo

Example
Dim ColumnInfo As SEGColumnInfo

Set ColumnInfo = Accessor.GetColumnInfoItem(1)
MsgBox ColumnInfo.SortPosition

SortedBy Property
Syntax

object.SortedBy

Remarks

A value specifying whether the data source is currently sorted by this value. The value returned is a VARIANT_BOOL and can be true or false.

Member of SASAIOBJLib.SEGColumnInfo

Example
Dim ColumnInfo As SEGColumnInfo

Set ColumnInfo = Accessor.GetColumnInfoItem(1)
MsgBox ColumnInfo.SortedBy

Indexed Property
Syntax

object.Indexed

Remarks

Use this routine to determine if the column is indexed. The value returned is a VARIANT_BOOL and can be true or false.

Member of SASAIOBJLib.SEGColumnInfo

Example
Dim ColumnInfo As SEGColumnInfo

Set ColumnInfo = Accessor.GetColumnInfoItem(1)
MsgBox ColumnInfo.Indexed

MissingAllowed Property
Syntax

object.MissingAllowed

Remarks

Use this routine to determine if the column allows missing values. The value returned is a VARIANT_BOOL and can be true or false.

Member of SASAIOBJLib.SEGColumnInfo

Example
Dim ColumnInfo As SEGColumnInfo

Set ColumnInfo = Accessor.GetColumnInfoItem(1)
MsgBox ColumnInfo.MissingAllowed

Offset Property
Syntax

object.Offset

Remarks

Use this routine to get the zero-based offset of the column.

Member of SASAIOBJLib.SEGColumnInfo

Example
Dim ColumnInfo As SEGColumnInfo

Set ColumnInfo = Accessor.GetColumnInfoItem(1)
MsgBox ColumnInfo.Offset

DisplayName Property
Syntax

object.DisplayName

Remarks

Use this routine to get the label for the column.

Member of SASAIOBJLib.SEGColumnInfo

Example
Dim ColumnInfo As SEGColumnInfo

Set ColumnInfo = Accessor.GetColumnInfoItem(1)
MsgBox ColumnInfo.DisplayName

Format Property
Syntax

object.Format

Remarks

Use this routine to get the SAS format value.

Member of SASAIOBJLib.SEGColumnInfo

Example
Dim ColumnInfo As SEGColumnInfo

Set ColumnInfo = Accessor.GetColumnInfoItem(1)
MsgBox ColumnInfo.Format

Columns Property
Syntax

object.Columns

Remarks

Use this routine to get the total columns for a data source.

Member of SASAIOBJLib.SEGAccessor

Example
Dim Data As SEGData
Dim Accessor As SEGAccessor

Set Data = Application.GetActiveData()
Set Accessor = Data.GetAccessor()

MsgBox "Total Columns = " & CStr(Accessor.Columns)

Rows Property
Syntax

object.Rows

Remarks

Use this routine to get the total rows for a data source.

Member of SASAIOBJLib.SEGAccessor

Example
Dim Data As SEGData
Dim Accessor As SEGAccessor

Set Data = Application.GetActiveData()
Set Accessor = Data.GetAccessor()

MsgBox "Total Rows = " & CStr(Accessor.Rows)

GetColumnInfoItem Method
Syntax

object.GetColumnInfoItem column

Parameters

column
A zero-based index or the variable name for the column.

Return Values

Returns a SEGColumnInfo object.

Remarks

Use this routine to get an instance of the SEGColumnInfo object. The SEGColumnInfo object provides access to an individual column's properties.

Member of SASAIOBJLib.SEGAccessor

Example
Dim Data As SEGData
Dim Accessor As SEGAccessor
Dim ColumnInfo As SEGColumnInfo

Set Data = Application.GetActiveData()
Set Accessor = Data.GetAccessor()

Set ColumnInfo = Accessor.GetColumnInfoItem("name")

GetRawValue Method
Syntax

object.GetRawValue column, row, missing

Parameters

column
A zero-based index or the variable name for the column.
row
A zero-based index that represents the row offset.
missing
The missing value receives a VARIANT_BOOL, which can be true or false.

Return Values

Returns the variant data value in raw form.

Remarks

The missing parameter is a VARIANT_BOOL and can be true or false.. The value returned is the actual value stored in the data set. It is in unformatted form.

Member of SASAIOBJLib.SEGAccessor

Example
Dim Data As SEGData
Dim Accessor As SEGAccessor
Dim Missing As Boolean
Dim Value As Variant

Set Data = Application.GetActiveData()
Set Accessor = Data.GetAccessor()

Value  = Accessor.GetRawValue("name", 0, Missing)

GetFormattedValue Method
Syntax

object.GetFormattedValue column, row, missing

Parameters

column
The zero-based index or the variable name for the column.
row
A zero-based index that represents the row offset.
missing
The missing value receives a VARIANT_BOOL, which can be true or false.

Return Values

Returns the Variant value in formatted form.

Remarks

The missing parameter is a VARIANT_BOOL and can be true or false. The value returned is the formatted value derived from the raw value stored in the data set. It is in formatted form.

Member of SASAIOBJLib.SEGAccessor

Example
Dim Data As SEGData
Dim Accessor As SEGAccessor
Dim Missing As Boolean
Dim Value As Variant

Set Data = Application.GetActiveData()
Set Accessor = Data.GetAccessor()

Value  = Accessor.GetFormattedValue("name", 0, Missing)

GetColumnList Method

Syntax

object.GetColumnList variablearray

Parameters

variablearray
Receives a list of column variable names associated with the data source. The variablearray is in the form of a SAFEARRAY(BSTR), which represents an array of string values.

Remarks

Member of SASAIOBJLib.SEGAccessor

Example
Dim Data As SEGData
Dim Accessor As SEGAccessor
Dim VariableArray() As String

Set Data = Application.GetActiveData()
Set Accessor = Data.GetAccessor()

Accessor.GetColumnList VariableArray

GetColumnInfoList Method
Syntax

object.GetColumnInfoList columninfoarray

Parameters

columninfoarray
Receives a list of column SEGColumnInfo objects, each representing an individual column in the data source. The columninfoarray is in the form of a SAFEARRAY(ISEGColumnInfo), which represents an array of SEGColumnInfo objects.

Remarks

Member of SASAIOBJLib.SEGAccessor

Example
Dim Data As SEGData
Dim Accessor As SEGAccessor
Dim ColumnInfoArray() As SEGColumnInfo

Set Data = Application.GetActiveData()
Set Accessor = Data.GetAccessor()

Accessor.GetColumnInfoList ColumnInfoArray

Visual Basic Summary Statistics Code Example

Option Explicit

Implements SEGAddIn
Implements SEGTask
Implements SEGTaskInfo
Implements SEGErrorSink
Implements SEGDataSink

Private Task As Dialog

Private Sub SEGAddIn_Connect(ByVal ppiApplication As SASAIOBJLib.ISEGApplication, ByVal lCookie As Long, plSuccess As Long)
    Set Task = New Dialog
    Set Task.Application = ppiApplication
    plSuccess = APP_CONNECTION_SUCCESS
End Sub

Private Sub SEGAddIn_Disconnect()
    Unload Task
End Sub

Private Sub SEGAddIn_GetDescription(pbstrVal As String)
    pbstrVal = "Tests the AddIn Support and utilizes the SAS Value Selector"
End Sub

Private Sub SEGAddIn_GetName(pbstrVal As String)
    pbstrVal = "Sample Means"
End Sub

Private Sub SEGDataSink_ActiveDataChanged()
    'Do Nothing
End Sub

Private Sub SEGDataSink_GenerateOutputData(plSuccess As Long)
    'Do Nothing
End Sub

Private Sub SEGDataSink_GenerateOutputDataNames()
    Task.GenerateOutputDataNames
End Sub

Private Sub SEGErrorSink_ExecutionError(ByVal lErrorCode As Long, ByVal bstrDescription As String, ByVal bstrProgID As String, ByVal bstrMethod As String, ByVal bstrParameter As String)
    MsgBox bstrDescription & vbCrLf & _
        "Function :" & bstrMethod & vbCrLf & _
        "Parameter : " & bstrParameter
End Sub

Private Sub SEGTask_GetOptionsFlag(plOptions As Long)
    'Do Nothing
End Sub

Private Sub SEGTask_GetOutputDataCount(plCount As Long)
    plCount = 0
    If Task.SaveStatistics.Value = 1 Then
       plCount = 1
    End If
End Sub

Private Sub SEGTask_GetOutputDataInfo(ByVal lIndex As Long, pbstrSource As String, pbstrLabel As String, plFile As Long)

    If lIndex = 0 Then
        pbstrSource = Task.OutputLibref & "." & Task.OutputMember
        pbstrLabel = "Generated Data"
        plFile = APP_OUTPUTDATA_LIBREF
    End If

End Sub

Private Sub SEGTask_GetProperty(ByVal bstrKey As String, pbstrVal As String)
    'Set the form value when a persisted property is encountered
    'This routine is called from the application to load values from the project
    If bstrKey = "Mean" Then pbstrVal = CStr(Task.Mean.Value) Else
    If bstrKey = "StandardDeviation" Then pbstrVal = CStr(Task.StandardDeviation.Value) Else
    If bstrKey = "StandardError" Then pbstrVal = CStr(Task.StandardError.Value) Else
    If bstrKey = "Variance" Then pbstrVal = CStr(Task.Variance.Value) Else
    If bstrKey = "Minimum" Then pbstrVal = CStr(Task.Minimum.Value) Else
    If bstrKey = "Maximum" Then pbstrVal = CStr(Task.Maximum.Value) Else
    If bstrKey = "Range" Then pbstrVal = CStr(Task.Range.Value) Else
    If bstrKey = "Sum" Then pbstrVal = CStr(Task.Sum.Value) Else
    If bstrKey = "NumberOfObservations" Then pbstrVal = CStr(Task.NumberOfObservations.Value) Else
    If bstrKey = "NumberOfMissingValues" Then pbstrVal = CStr(Task.NumberOfMissingValues.Value) Else
    If bstrKey = "Combo1" Then pbstrVal = CStr(Task.Combo1.ListIndex) Else
    If bstrKey = "Combo2" Then pbstrVal = CStr(Task.Combo2.ListIndex) Else
    If bstrKey = "P1" Then pbstrVal = CStr(Task.P1.Value) Else
    If bstrKey = "P5" Then pbstrVal = CStr(Task.P5.Value) Else
    If bstrKey = "P10" Then pbstrVal = CStr(Task.P10.Value) Else
    If bstrKey = "P25" Then pbstrVal = CStr(Task.P25.Value) Else
    If bstrKey = "P50" Then pbstrVal = CStr(Task.P50.Value) Else
    If bstrKey = "P75" Then pbstrVal = CStr(Task.P75.Value) Else
    If bstrKey = "P90" Then pbstrVal = CStr(Task.P90.Value) Else
    If bstrKey = "P95" Then pbstrVal = CStr(Task.P95.Value) Else
    If bstrKey = "P99" Then pbstrVal = CStr(Task.P99.Value) Else
    If bstrKey = "SaveStatistics" Then pbstrVal = CStr(Task.SaveStatistics.Value) Else
    If bstrKey = "ShowStatistics" Then pbstrVal = CStr(Task.ShowStatistics.Value) Else
    If bstrKey = "AllWay" Then pbstrVal = CStr(Task.AllWay.Value) Else
    If bstrKey = "NWay" Then pbstrVal = CStr(Task.NWay.Value) Else
    If bstrKey = "SpecificWay" Then pbstrVal = CStr(Task.SpecificWay.Value) Else
    If bstrKey = "SpecificTextBox" Then pbstrVal = Task.SpecificTextBox.Text Else
    If bstrKey = "Analysis variables" Then pbstrVal = Task.RoleValues("Analysis variables") Else
    If bstrKey = "Classification variables" Then pbstrVal = Task.RoleValues("Classification variables")
End Sub

Private Sub SEGTask_GetPropertyList(pbstrKeyArray() As String)
    'This routine is called from the application to load values from the project
    ReDim pbstrKeyArray(28) As String
    pbstrKeyArray(0) = "Mean"
    pbstrKeyArray(1) = "StandardDeviation"
    pbstrKeyArray(2) = "StandardError"
    pbstrKeyArray(3) = "Variance"
    pbstrKeyArray(4) = "Minimum"
    pbstrKeyArray(5) = "Maximum"
    pbstrKeyArray(6) = "Range"
    pbstrKeyArray(7) = "Sum"
    pbstrKeyArray(8) = "NumberOfObservations"
    pbstrKeyArray(9) = "NumberOfMissingValues"
    pbstrKeyArray(10) = "Combo1"
    pbstrKeyArray(11) = "Combo2"
    pbstrKeyArray(12) = "P1"
    pbstrKeyArray(13) = "P5"
    pbstrKeyArray(14) = "P10"
    pbstrKeyArray(15) = "P25"
    pbstrKeyArray(16) = "P50"
    pbstrKeyArray(17) = "P75"
    pbstrKeyArray(18) = "P90"
    pbstrKeyArray(19) = "P95"
    pbstrKeyArray(20) = "P99"
    pbstrKeyArray(21) = "SaveStatistics"
    pbstrKeyArray(22) = "ShowStatistics"
    pbstrKeyArray(23) = "NWay"
    pbstrKeyArray(24) = "AllWay"
    pbstrKeyArray(25) = "SpecificWay"
    pbstrKeyArray(26) = "SpecificTextBox"
    pbstrKeyArray(27) = "Analysis variables"
    pbstrKeyArray(28) = "Classification variables"
End Sub

Private Sub SEGTask_GetRequiresData(plVal As Long)
    plVal = APP_DATAOPTION_REQUIRED
End Sub

Private Sub SEGTask_GetRunLog(pbstrVal As String)
    'Do Nothing
End Sub

Private Sub SEGTask_GetSubmitCode(pbstrCode As String)
    pbstrCode = Task.Code
End Sub

Private Sub SEGTask_Initialize(plSuccess As Long)
    Task.Initialize
    plSuccess = APP_INITIALIZE_SUCCESS
End Sub

Private Sub SEGTask_SetProperty(ByVal bstrKey As String, ByVal bstrVal As String)
    'Get the form value when a persisted property is encountered
    'This routine is called from the application to save values to the project
    If bstrKey = "Mean" Then Task.Mean.Value = CInt(bstrVal) Else
    If bstrKey = "StandardDeviation" Then Task.StandardDeviation.Value = CInt(bstrVal) Else
    If bstrKey = "StandardError" Then Task.StandardError.Value = CInt(bstrVal) Else
    If bstrKey = "Variance" Then Task.Variance.Value = CInt(bstrVal) Else
    If bstrKey = "Minimum" Then Task.Minimum.Value = CInt(bstrVal) Else
    If bstrKey = "Maximum" Then Task.Maximum.Value = CInt(bstrVal) Else
    If bstrKey = "Range" Then Task.Range.Value = CInt(bstrVal) Else
    If bstrKey = "Sum" Then Task.Sum.Value = CInt(bstrVal) Else
    If bstrKey = "NumberOfObservations" Then Task.NumberOfObservations.Value = CInt(bstrVal) Else
    If bstrKey = "NumberOfMissingValues" Then Task.NumberOfMissingValues.Value = CInt(bstrVal) Else
    If bstrKey = "Combo1" Then Task.Combo1.ListIndex = CInt(bstrVal) Else
    If bstrKey = "Combo2" Then Task.Combo2.ListIndex = CInt(bstrVal) Else
    If bstrKey = "P1" Then Task.P1.Value = CInt(bstrVal) Else
    If bstrKey = "P5" Then Task.P5.Value = CInt(bstrVal) Else
    If bstrKey = "P10" Then Task.P10.Value = CInt(bstrVal) Else
    If bstrKey = "P25" Then Task.P25.Value = CInt(bstrVal) Else
    If bstrKey = "P50" Then Task.P50.Value = CInt(bstrVal) Else
    If bstrKey = "P75" Then Task.P75.Value = CInt(bstrVal) Else
    If bstrKey = "P90" Then Task.P90.Value = CInt(bstrVal) Else
    If bstrKey = "P95" Then Task.P95.Value = CInt(bstrVal) Else
    If bstrKey = "P99" Then Task.P99.Value = CInt(bstrVal) Else
    If bstrKey = "SaveStatistics" Then Task.SaveStatistics.Value = CInt(bstrVal) Else
    If bstrKey = "ShowStatistics" Then Task.ShowStatistics.Value = CInt(bstrVal) Else
    If bstrKey = "AllWay" Then Task.AllWay.Value = CBool(bstrVal) Else
    If bstrKey = "NWay" Then Task.NWay.Value = CBool(bstrVal) Else
    If bstrKey = "SpecificWay" Then Task.SpecificWay.Value = CBool(bstrVal) Else
    If bstrKey = "SpecificTextBox" Then Task.SpecificTextBox.Text = bstrVal Else
    If bstrKey = "Analysis variables" Then Task.AssignRoleValues "Analysis variables", bstrVal Else
    If bstrKey = "Classification variables" Then Task.AssignRoleValues "Classification variables", bstrVal
End Sub

Private Sub SEGTask_Show(ByVal lParentWindowHandle As Long, plStatus As Long)
    'Reset the plStatus value
    plStatus = APP_SHOW_CANCELED

    'Display the Form
    Task.Show vbModal
    If Task.OkSelected = True Then
        plStatus = APP_SHOW_RUNNOW
    End If
End Sub

Private Sub SEGTask_Terminate()
    Unload Task
End Sub

Private Sub SEGTaskInfo_GetTaskCategory(pbstrVal As String)
    pbstrVal = "Custom"
End Sub

Private Sub SEGTaskInfo_GetTaskDescription(pbstrVal As String)
    pbstrVal = "AddIn Test"
End Sub

Private Sub SEGTaskInfo_GetTaskMajorVersion(plVal As Long)
    plVal = 1
End Sub

Private Sub SEGTaskInfo_GetTaskMinorVersion(plVal As Long)
    plVal = 1
End Sub

Private Sub SEGTaskInfo_GetTaskName(pbstrVal As String)
    pbstrVal = "Summary Statistics"
End Sub

Private Sub SEGTaskInfo_GetTaskProcsUsed(pbstrVal As String)
    pbstrVal = "MEANS"
End Sub

Private Sub SEGTaskInfo_GetTaskType(plType As Long)
    plType = APP_TASKTYPE_WIZARD
End Sub

Private Sub SEGTaskInfo_GetTaskValidation(pbstrVal As String)
    pbstrVal = "Example"
End Sub

 Option Explicit

Public OkSelected As Boolean
Public OutputMember As String
Public OutputLibref As String
Public Application As SEGApplication

Private Sub CancelButton_Click()
    OkSelected = False
    Hide
End Sub

Function RoleValues(ByVal strRole) As String
    Dim Variable As String
    Dim Count As Long
    Dim Index As Long
    Dim lResult As Long

    Count = VariableSelector_V31.GetNumberAssignedVars(strRole)
    Index = 0
    While Index < Count
        Variable = Application.GetValidLiteral(VariableSelector_V31.GetAssignedVar(strRole, Index))
        RoleValues = RoleValues + Variable
        Index = Index + 1
        If Index < Count Then
            RoleValues = RoleValues + " "
        End If
    Wend
End Function

Function GenerateOutputDataNames()
    Dim Data As SEGData

    'Initialize our data access objects
    Set Data = Application.GetActiveData()

    OutputLibref = "SASUSER"
    OutputMember = Application.CreateMemberName(Data.Server, OutputLibref, "ADDIN")
End Function

Function AssignRoleValues(ByVal strRole, ByVal strValue)
    Dim Variable As String
    Dim InBuffer As String
    Dim OutBuffer As String

    InBuffer = strValue
    Do
        'Iterate through the delimited string
        Variable = Application.GetNextVariable(InBuffer, OutBuffer)
        VariableSelector_V31.AssignVariable Variable, strRole
        InBuffer = OutBuffer
    Loop Until Variable = ""
End Function

Function Initialize()
    Dim Value As Variant
    Dim Index As Long
    Dim Count As Long
    Dim lType As Long

    Dim Data As SEGData
    Dim Accessor As SEGAccessor
    Dim ColumnInfo() As SEGColumnInfo

    'Initialize our data access objects
    Set Data = Application.GetActiveData()
    Set Accessor = Data.GetAccessor()

    If OutputMember = "" Then
        GenerateOutputDataNames
    End If

    'Assign the roles for our Variable Selector
    VariableSelector_V31.AddRole "Analysis variables", 5, 0, False, False, "", "", "", "", "", 1
    VariableSelector_V31.AddRole "Classification variables", 0, 0, False, False, "", "", "", "", "", 0

    'Initialize the variable selector with application option settings
    Value = Application.GetOption(APP_OPTION_SHOW_COLUMN_LABEL)
    VariableSelector_V31.SetShowLabels Value

    Value = Application.GetOption(APP_OPTION_DISPLAY_COLUMN_ALPHA_ORDER)
    VariableSelector_V31.SetSortVarsByName Value

    'Initial values for the form
    SSTab1.Tab = 0
    Combo1.ListIndex = 0
    Combo2.ListIndex = 9
    OkSelected = False

    'Get the list of SEGColumnInfo objects
    Accessor.GetColumnInfoList ColumnInfo()

    Index = LBound(ColumnInfo)
    Count = UBound(ColumnInfo)
    'Populate the Variable Selector control
    Do While Index <= Count
        VariableSelector_V31.AddVariable_V2 _
            ColumnInfo(Index).VariableName, _
            ColumnInfo(Index).DisplayName, _
            ColumnInfo(Index).DisplayName, _
            ColumnInfo(Index).Offset, _
            ColumnInfo(Index).VariableGroup, _
            ColumnInfo(Index).Length, _
            ColumnInfo(Index).Format, _
            ColumnInfo(Index).Informat, _
            ColumnInfo(Index).SortedBy
        Index = Index + 1
    Loop

    Dim bRC As Boolean
    'Pass the Variable Selector our data object so it can
    '  handle displaying the formats for the data
    bRC = VariableSelector_V31.SetDataModelUnknown(Data)
    If bRC = False Then
        MsgBox ("Means SetDataModelUnknown returned FALSE.")
    End If

End Function

Function Code() As String
    Dim Index As Long
    Dim Count As Long
    Dim File As String
    Dim TimeStamp As String
    Dim DateStamp As String
    Dim Server As String
    Dim Libref As String
    Dim VarAssigned As String
    Dim VarLiteral As String
    Dim Member As String
    Dim Data As SEGData

    'Initialize our data access objects
    Set Data = Application.GetActiveData()

    File = Data.File
    DateStamp = Format(Now, "Long Date")
    TimeStamp = Time
    Server = Data.Server
    Libref = Data.Libref
    Member = UCase(Data.Member)

    Count = VariableSelector_V31.GetNumberAssignedVars("Analysis variables")
    Index = 0
    While Index < Count
        VarAssigned = VariableSelector_V31.GetAssignedVar("Analysis variables", Index)
        VarLiteral = VarLiteral & Application.GetValidLiteral(VarAssigned)

        Index = Index + 1
        If Index < Count Then
            VarLiteral = VarLiteral + " "
        End If
    Wend

    'Comment
    Code = Code & "/*------------------------------------------------------" & vbCrLf
    Code = Code & vbTab & "Code generated by SAS Enterprise Guide" & vbCrLf
    Code = Code & vbTab & "DATE: " & DateStamp & vbTab & "TIME: " & TimeStamp & vbCrLf
    Code = Code & vbTab & "TASK: Simple Summary Statistics" & vbCrLf
    Code = Code & vbTab & "SERVER: " & Server & vbCrLf
    Code = Code & vbTab & "DATA: " & File & vbCrLf
    Code = Code & "-------------------------------------------------------*/" & vbCrLf
    Code = Code & vbCrLf

    'Footnote
    Code = Code & "FOOTNOTE ""Generated by the SAS System (" & Server & ", &SYSSCPL) on "
    Code = Code & "%SYSFUNC(DATE(), EURDFDE9.) at %SYSFUNC(TIME(), TIMEAMPM8.)"";" & vbCrLf
    Code = Code & vbCrLf

    'Comment
    Code = Code & "/*-----------------------------------------------------" & vbCrLf
    Code = Code & vbTab & "Call PROC MEANS to do the analysis." & vbCrLf
    Code = Code & "*/" & vbCrLf
    Code = Code & vbCrLf

    'Titles
    Code = Code & "TITLE1 ""Simple Summary Statistics"";" & vbCrLf
    Code = Code & "TITLE2 ""Results"";" & vbCrLf
    Code = Code & vbCrLf

    'Proc
    Code = Code & "PROC MEANS DATA=" & Libref & "." & Member
    If ShowStatistics.Value = 1 Then
        Code = Code & "  FW=12" & vbCrLf
        If Combo2.ListIndex >= 0 And Combo2.ListIndex <= 8 Then
            Code = Code & vbTab & "MAXDEC=" & Combo2.List(Combo2.ListIndex) & vbCrLf
        End If
        Code = Code & vbTab & "PRINTALLTYPES" & vbCrLf
    Else
        Code = Code & vbCrLf
    End If

    Code = Code & vbTab & "CHARTYPE" & vbCrLf

    If NWay.Value = True Then
        Code = Code & vbTab & "NWAY" & vbCrLf
    End If

    Code = Code & vbTab & "VARDEF = DF" & vbCrLf

    If Maximum.Value = 1 Then
        Code = Code & vbTab & "MAX" & vbCrLf
    End If

    If Mean.Value = 1 Then
        Code = Code & vbTab & "MEAN" & vbCrLf
    End If

    If Minimum.Value = 1 Then
        Code = Code & vbTab & "MIN" & vbCrLf
    End If

    If NumberOfObservations.Value = 1 Then
        Code = Code & vbTab & "N" & vbCrLf
    Else
        Code = Code & vbTab & "NONOBS" & vbCrLf
    End If

    If NumberOfMissingValues.Value = 1 Then
        Code = Code & vbTab & "NMISS" & vbCrLf
    End If

    If Range.Value = 1 Then
        Code = Code & vbTab & "RANGE" & vbCrLf
    End If

    If StandardDeviation.Value = 1 Then
        Code = Code & vbTab & "STDDEV" & vbCrLf
    End If

    If StandardError.Value = 1 Then
        Code = Code & vbTab & "STDERR" & vbCrLf
    End If

    If Sum.Value = 1 Then
        Code = Code & vbTab & "SUM" & vbCrLf
    End If

    If P1.Value = 1 Then
        Code = Code & vbTab & "P1" & vbCrLf
    End If

    If P5.Value = 1 Then
        Code = Code & vbTab & "P5" & vbCrLf
    End If

    If P10.Value = 1 Then
        Code = Code & vbTab & "P10" & vbCrLf
    End If

    If P25.Value = 1 Then
        Code = Code & vbTab & "P25" & vbCrLf
    End If

    If P50.Value = 1 Then
        Code = Code & vbTab & "P50" & vbCrLf
    End If

    If P75.Value = 1 Then
        Code = Code & vbTab & "P75" & vbCrLf
    End If

    If P90.Value = 1 Then
        Code = Code & vbTab & "P90" & vbCrLf
    End If

    If P95.Value = 1 Then
        Code = Code & vbTab & "P95" & vbCrLf
    End If

    If P99.Value = 1 Then
        Code = Code & vbTab & "P99" & vbCrLf
    End If

    If P1.Value = 1 Or P5.Value = 1 Or P10.Value = 1 Or _
        P25.Value = 1 Or P50.Value = 1 Or P75.Value = 1 Or _
        P90.Value = 1 Or P95.Value = 1 Or P99.Value = 1 Then
        If Combo1.ListIndex = 0 Then
            Code = Code & vbTab & "QMETHOD=OS" & vbCrLf
        Else
            Code = Code & vbTab & "QMETHOD=P2" & vbCrLf
        End If
    End If

    Code = Code & ";" & vbCrLf
    Code = Code & "VAR " & VarLiteral & ";" & vbCrLf

    Index = 0
    Count = VariableSelector_V31.GetNumberAssignedVars("Classification variables")
    While Index < Count
        Code = Code & "CLASS " & Application.GetValidLiteral( _
            VariableSelector_V31.GetAssignedVar("Classification variables", Index)) & _
            " / ORDER=UNFORMATTED;" & vbCrLf
        Index = Index + 1
    Wend

    If SpecificWay.Value = True Then
        Code = Code & "WAYS " & SpecificTextBox.Text & ";" & vbCrLf
    End If

    'Uses the same options each time. With more time this should be expanded to match
    '   the options selected but for demonstration purpose this is fine
    If SaveStatistics.Value = 1 Then
        Code = Code & "OUTPUT OUT=" & OutputLibref & "." & OutputMember & "(LABEL=""Summary statistics for " & Libref & "." & Member & """)" & vbCrLf
        Code = Code & vbTab & "MAX()=" & vbCrLf
        Code = Code & vbTab & "MEAN()=" & vbCrLf
        Code = Code & vbTab & "MIN()=" & vbCrLf
        Code = Code & vbTab & "N()=" & vbCrLf
        Code = Code & vbTab & "STDDEV()=" & vbCrLf
        Code = Code & vbTab & "/ AUTONAME WAYS INHERIT;" & vbCrLf
    End If

    Code = Code & "RUN;" & vbCrLf
    Code = Code & "TITLE;FOOTNOTE;RUN;" & vbCrLf
End Function

Private Sub OKButton_Click()
    OkSelected = True
    Hide
End Sub

Private Sub VariableSelector_V31_ShouldPropertyEditingBeEnabled(ByVal strVarName As String, pbEditLabel As Boolean, pbEditFormat As Boolean)
    pbEditFormat = True
    pbEditLabel = True
End Sub


Customizing Enterprise Guide

Using ActiveX Controls

  1. SAS Variable Selector Control
    1. SAS Variable Selector Control Properties
    2. SAS Variable Selector Control Methods
    3. SAS Variable Selector Control Events
  2. SAS Color Selector Control
    1. SAS Color Selector Control Properties
    2. SAS Color Selector Control Methods
    3. SAS Color Selector Control Events
  3. SAS Properties Control
    1. SAS Properties Control Properties
    2. SAS Properties Control Methods
    3. SAS Properties Control Events
  4. SAS Option Selector Control
    1. SAS Option Selector Control Properties
    2. SAS Option Selector Control Methods
    3. SAS Option Selector Control Events
  5. SAS Format/Informat Selector Control
    1. SAS Format/Informat Selector Control Properties
    2. SAS Format/Informat Selector Control Methods
    3. SAS Format/Informat Selector Control Events
  6. SAS Data Set Selector Control
    1. SAS Data Set Selector Control Properties
    2. SAS Data Set Selector Control Events
  7. SAS Enhanced Editor Control
    1. SAS Enhanced Editor Control Properties

SAS Variable Selector Control

The SAS Variable Selector control displays a list of columns (variables) and a list of roles to which the columns may be assigned. The validity of assigning a particular variable to a given role is governed by a number of rules which may be defined for each role. This control is one of the most recognizable of all the ActiveX controls used in Enterprise Guide as it appears on every task's Column tab.

File Name

SASVaSel.OCX

Current Interface Version

3

Current CoClass Name

VariableSelector_V3

Properties Overview

BackSysColorId | Specifies the color the control should use to paint its background.
ColumnRolesTitle | Replaces the default text used as the title for the roles' tree control.
ControlSplitPercentage | The percentage of the control at which the split between the list and tree controls should be placed.
ColumnsToAssignTitle | Replaces the default text used as the title for the variables list control.
PredefinedDataItemName | Specifies whether the word "Columns" or "Variables" should be used in the labels for the list and tree controls.

Methods Overview

AcceptanceChecking | Enables or disables the limiting of acceptable variables for the specified role to those in the acceptable variables list.
AddAcceptableVar | Adds a variable to the list of acceptable variables for the specified role.
AddRole_V2 | Defines a role, its attributes and the various rules for assigning variables to it.
AddVariable_V2 | Adds a variable, along with a description of its various properties, to the control.
AssignVariable | Assigns a variable to a role.
BeginMultipleAddVariableCalls | Indicates that numerous calls to the AddVariable_V2 method are about to take place and that the control should not perform a sort of the variables list control after each new variable is added. The associated method EndMultipleAddVariableCalls should be called once the calls to the AddVariable_V2 method have completed. Using these two methods provides a major performance improvement when adding large numbers of variables to the control.
DeassignAllVariables | Removes all variable assignments to all roles.
DeassignVariable | Deassigns a variable from a role.
DeselectListView | Removes all selections from items within the list of variables.
EndMultipleAddVariableCalls | Indicates that numerous calls of the AddVariable_V2 method are now completed and that the control should now perform a sort of the variables list control. Refer to the associated method BeginMultipleAddVariableCalls for additional information. Using these two methods provides a major performance improvement when adding large numbers of variables to the control.
GetAssignedVar | Returns the name of the variable at the specified index position within those variables assigned to a role.
GetAssignedVarIndex | Determines a variable's index position within a role's assigned variables.
GetFirstRole | Returns an internal key to the first role within the control.
GetFirstSelectedAssignedVar | Returns the name of the first selected variable assigned to a role.
GetMessageIndex | Retrieves one of the messages waiting as a result of calling AssignVariable(). The maximum index value is determined from the value supplied by the MessagesWaiting event.
GetNextRole | Returns the name of the role at the specified position and an internal key to the next role.
GetNextSelectedAssignedVar | Returns the name of the next selected variable assigned to the specified role.
GetNumberAssignedVars | Returns the number of variables assigned to the specified role.
GetNumberOfAssignedVarsSelected | Returns the number of assigned variables that are selected.
GetNumberOfRoles | Returns the number of roles added to the control.
GetNumberOfVarsListSelections | Returns the number of variables currently selected within the variables list.
GetRoleProperty | Retrieves the current value of various role attributes.
GetShowLabels | Returns a Boolean value indicating whether labels or names are displayed for columns.
GetSortByNameAscending | Returns a Boolean value indicating whether the variable Names/Labels are sorted in an ascending sequence.
GetSorted | Gets the sort type for a variable within a role.
GetSortVarsByName | Returns a Boolean value indicating whether the variables are sorted by Name/Label or by the order within the data source.
GetVarsFormat | Gets the current format for a variable.
GetVarsListSelectedItem | Used for retrieving the name of a selected variable at a particular index position within the variables list. The maximum index value is determined by calling GetNumberOfVarsListSelections().
GetVarsTaskLabel | Gets the current task label for a variable.
RemoveAcceptableVar | Removes a variable from the list of acceptable variables for the specified role.
RemoveAllAcceptableVars | Removes all variables from the list of acceptable variables for the specified role.
RemoveAllRoleSelections | Removes all item selections within all roles.
RemoveAllVariables | Removes all variables defined to the control.
RemoveAllRoles | Removes all roles defined to the control.
RemoveRole | Removes a role definition from the control.
RemoveVariable | Removes a variable definition from the control.
SelectAssignedVar | Selects a particular variable within a role.
SetDataModelUnknown | Supplies the control with a pointer to the SAS Data Model's IUnknown interface. (Used by the control during format enumeration.)
SetRoleProperty | Modifies various role attribute values.
SetShowLabels | Sets whether labels or names should be displayed for columns.
SetSortByNameAscending | Sets whether the variable Names/Labels are to be sorted in an ascending sequence.
SetSorted | Sets the sort order indicator for a particular variable within a role.
SetSortVarsByName | Sets whether variables should be initially sorted by Name/Label or order within the data source.
SetVarsFormat | Sets the current format for a variable.
SetVarsTaskLabel | Sets the current task label for a variable.

Events Overview

DeassignmentsFromRolesEnded | Occurs when all of the deassignments resulting from the last action have been completed.
MessagesWaiting | Occurs whenever there are one or more messages, resulting from a variable assignment or deassignment operation, waiting to be retrieved. Use the method GetMessageIndex() to retrieve each message.
RoleDnDActionEnded | Occurs once a drag and drop operation has completed (either successfully or unsuccessfully).
RoleHover | Occurs during a drag and drop operation to indicate the name of the role that the mouse pointer is currently hovering over.
RoleVarsSelectionChanged | Occurs when there has been a change in the selection state of items assigned to one or more roles.
ShouldPropertyEditingBeEnabled | Occurs immediately before the properties dialog for a variable is displayed to determine whether editing of the variable's label and/or format should be allowed.
ShowHourGlass | Occurs whenever the control is performing some task which prevents it from responding to user requests. A flag is set to indicate that the hourglass should be displayed by the task.
ShowLabelsChanged | Occurs whenever the user has toggled the display of variable names or labels.
SortByNameAscendingChanged | Occurs when the user has toggled the sort order of variable names/labels to ascending.
SortVarsByNameChanged | Occurs when the user has toggled the sorting of variables by names/labels or data set order.
VarFormatChanged | Occurs whenever a variable's format has been modified within the properties dialog.
VariableAssigned | Occurs whenever a variable is assigned to a role. A flag is set to indicate whether all of the rules for all roles are satisfied.
VariableDeassigned | Occurs whenever a variable is deassigned from a role. A flag is set to indicate whether all of the rules for all roles are now satisfied.
VariableNotAcceptableToRole | Occurs whenever an attempt is made to assign a variable to a role and that variable is not among the list of acceptable variables for the role.
VariableSequenceChanged | Occurs when the order of one or more variables within a role have changed.
VarsListSelectionChanged | Occurs if the selection state of items within the variables list has changed.
VarTaskLabelChanged | Occurs whenever a variable's label has been modified within the properties dialog.

SAS Variable Selector Control Properties

BackSysColorId Property
Sets the color used by the control to paint its background.

Syntax

SASVaSelObj.BackSysColorId = value

Parameters

value
An integer value specifying a COLOR_* value as is used by the Windows API function GetSysColor(). Refer to the Settings section for a list of some of the more common color values.

Settings

Some of the more common settings for value are:
1
COLOR_DESKTOP - Desktop color.

4
COLOR_MENU - Background color for menus.

5
COLOR_WINDOW - Background color for an application window's client area.

15
COLOR_BTNFACE - Face color for buttons and other three-dimensional objects, and the background color for a dialog's client area. This is the default.

Remarks

Specifying the same color as the parent's background color blends the control's child windows with the parent's other child windows.

Example

VariableSelector.BackSysColorId = 5     '  COLOR_WINDOW

ColumnRolesTitle Property
Replaces the default text used as the title (label) for the roles' tree control.

Syntax

SASVaSelObj.ColumnRolesTitle = value

Parameters

value
A string value which specifies the text to appear in the label associated with the roles' tree control. If the supplied value does not include a trailing semicolon, one will be appended automatically.

Specifying an empty string ("") will cause the default title to be used.

Example

VariableSelector.ColumnRolesTitle = "Assign the columns here:"

See Also

  • ColumnsToAssignTitle

  • PredefinedDataItemName

ControlSplitPercentage Property

Syntax

SASVaSelObj.ControlSplitPercentage = value

Parameters

value
An integer value between 15 and 85 inclusive which specifies the percentage of the control's width to be taken up by the "Columns to Assign" list control. The default value is 50, which gives a 50/50 split.

Remarks

If the user drags the split to a different position using the UI, the property value is updated to the new percentage value.

Example

VariableSelector.ControlSplitPercentage = 33    ' Changes the split to 33/67

ColumnsToAssignTitle Property

Syntax

SASVaSelObj.ColumnsToAssignTitle = value

Parameters

value
A string value which specifies the text to appear in the label associated with the variables list control. If the supplied value does not include a trailing semicolon, one is appended automatically. Specifying an empty string ("") causes the default title to be used.

Example

VariableSelector.ColumnsToAssignTitle = "Variables from the Data Source:"

See Also

  • ColumnRolesTitle

  • PredefinedDataItemName

PredefinedDataItemName Property
Specifies whether the word "Columns" or "Variables" should be used in the default labels for the list and tree controls and error text generated by the control.

Syntax

SASVaSelObj.PredefinedDataItemName = value

Parameters

value
An integer value which specifies an id that is used by the control to determine whether to use "Columns" or "Variables" within the text in error messages as well as the labels used by the tree and list controls. Refer to the Settings section below for a list of valid id values.

Settings

Valid settings for value are:

0
DINCODE_COLUMNS - "Column" and "Columns." This is the default.

1
DINCODE_VARIABLES - "Variable" and "Variables."

Remarks

The enumerated types DINCODE_COLUMNS and DINCODE_VARIABLES are defined within the control's type library.

Example

VariableSelector.PredefinedDataItemName = DINCODE_VARIABLES

See Also

  • ColumnRolesTitle

  • ColumnsToAssignTitle

SAS Variable Selector Control Methods

AcceptanceChecking Method
Enables or disables the limiting of the assignment of variables to those variables specified in its list of acceptable variables.

Syntax

SASVaSelObj.AcceptanceChecking (role, enabled)

Parameters

role
Required. A string value specifying the name of the role for which the acceptance checking state is to be modified.
enabled
Required. A Boolean value that enables or disables the acceptance checking for the role.

Returns

TRUE if successful or FALSE if an error condition occurred.

Remarks

This method is used in conjunction with the methods AddAcceptableVar, RemoveAcceptableVar and RemoveAllAcceptableVars to limit variables which may be assigned to the associated role.

Example

Dim bRC As Boolean

bRC = VariableSelector.AcceptanceChecking("Columns to print", True)

See Also

  • AddAcceptableVar

  • RemoveAcceptableVar

  • RemoveAllAcceptableVars

AddAcceptableVar Method
Adds a variable to the list of acceptable variables for a role.

Syntax

SASVaSelObj.AddAcceptableVar (role, variable)

Parameters

role
Required. A string value specifying the name of the role that is having a new variable appended to its list of acceptable variables.

variable
Required. A string value specifying the name of the variable being added to the list of acceptable variables.

Returns

TRUE if successful or FALSE if an error condition occurred.

Remarks

This method is used in conjunction with the RemoveAcceptableVar and RemoveAllAcceptableVars methods to manipulate the list of acceptable variables for a role. The method AcceptanceChecking is used to enable or disable the acceptance checking feature for a role.

Example

Dim bRC As Boolean
Dim strVarName as String

strVarName = "SalesId"

bRC = VariableSelector.AddAcceptableVar("Columns to print", strVarName)

See Also

  • AcceptanceChecking

  • RemoveAcceptableVar

  • RemoveAllAcceptableVars

AddRole_V2 Method
Defines a role, its attributes and the various rules for assigning variables to it.

Syntax

SASVaSelObj.AddRole_V2 (name, type, maxnumvars, dependencies, unique, exclusions, minnumvars)

Parameters

name
Required. A string value specifying the name of the new role to be added.

type
Required. An integer value specifying the types of variables which are acceptable for assignment to the role, as described in the Settings section.

maxnumvars
Required. An integer value between 1 and 32767 which specifies the maximum number of variables that may be assigned to the role. A value of 0 indicates that there is no limit and so in the current version of the control is equivalent to 32767.

dependencies
Required. A string value specifying a list of roles for which a variable must have previously been assigned before being assigned to this role. The list should be delimited by spaces, commas or semicolons and the role names should be enclosed in double quotes if they contain any of the delimiting characters. An empty string signifies that there are no dependencies.

unique
Required. A Boolean value where a TRUE value signifies that any variable assigned to this role should not be assignable to any other role. Once a variable is assigned to this role, it is removed from the list of available variables. Likewise, deassigning the variable from a role with this setting causes the variable to be added back into the list of available variables.

exclusions
Required. A string value specifying a list of roles to which a variable must not be assigned before being assigned to this role. The list should be delimited by spaces, commas or semicolons and the role names should be enclosed in double quotes if they contain any of the delimiting characters. An empty string signifies that there are no exclusions.

minnumvars
Required. An integer value specifying the minimum number of variables that must be assigned to this roles. A value of 0 signifies that there is no minimum number of variables required.

Settings

Valid settings for type are:

0
ALL (Numeric, Character, Date, Time and Currency)

2
ALL & GEOREF (GeoRef, Numeric, Character, Date, Time and Currency)

5
NUMERIC (Numeric, Date, Time and Currency)

8
CHARACTER (Character)

9
DATE (Date and Numeric)

10
TIME (Time and Numeric)

11
CURRENCY (Currency and Numeric)

14
GEOREF (GeoRef)

Returns

TRUE if successful or FALSE if an error condition occurred.

Remarks

Duplicate role names are not permitted. The role name supplied is used for all subsequent actions on or relating to the role.

This method must be called at least once before the control is enabled.

Example

Dim bRC As Boolean

bRC = VariableSelector.AddRole_V2("Columns to sum", 5, 0,
                 """Columns to print""", False,
               """Page By""", 1)

See Also

  • AddVariable_V2

  • RemoveRole

  • RemoveAllRoles

  • SetRoleProperty

AddVariable_V2 Method
Adds a variable along with its various attributes to the list of available variables.

Syntax

SASVaSelObj.AddVariable_V2 ( name, label, tasklabel, position, type, maxlength, format, informat, sortedby)

Parameters

name
Required. A string value specifying the name of the new variable to be added.

label
Required. A string value specifying the label associated with the variable.

tasklabel
Required. A string value which specifies a temporary label specific to this task which overrides the label specified in label. If this parameter is empty ("") then label is used.

position
Required. An integer value which specifies the ordinal number of the variable in a record within the data source.

type
Required. An integer value which specifies the type of information contained within the variable, as described in the Settings section.

maxlength
Required. An integer value which specifies the length of the variable's data when stored in a record within the data source.

format
Required. A string value specifying the format name and length associated with the variable. This value must be a valid SAS format specification.

informat
Required. A string value specifying the informat name and length associated with the variable. This value must be a valid SAS informat specification.

sortedby
Required. A Boolean value specifying whether the data source is currently sorted by this variable.

Settings

Valid settings for type are:

5
Numeric

8
Character

9
Date

10
Time

11
Currency

14
GeoRef

Returns

TRUE if successful or FALSE if an error condition occurred.

Remarks

Duplicate variable names are not permitted. The variable name supplied is used for all subsequent actions on or relating to the variable.

This method must be called at least once before the control will become enabled.

Example

Dim bRC As Boolean

bRC = VariableSelector.AddVariable_V2("SalesId", "Sales Region", "", 3, 5, 8, "Z4.", "", False)

See Also

  • BeginMultipleAddVariableCalls

  • EndMultipleAddVariableCalls

  • RemoveVariable

  • RemoveAllVariables

AssignVariable Method
Programmatically assigns a variable to a role.

Syntax

SASVaSelObj.AssignVariable (variable, role)

Parameters

variable
Required. A string value specifying the name of the variable to be assigned.

role
Required. A string value specifying the name of the role to which the variable is being assigned.

Returns

TRUE if successful or FALSE if an error condition occurred.

Remarks

All role and acceptability checking is performed during the attempt to assign the variable to the role.

Should an error occur during the attempted assignment, a MessagesWaiting event will occur after which calls may be made to the GetMessageIndex method to retrieve text strings which explain why the assignment could not be performed.

Example

Dim bRC As Boolean

bRC = VariableSelector.AssignVariable("Columns to print", "SalesId")

See Also

  • MessagesWaiting

  • GetMessageIndex

BeginMultipleAddVariableCalls Method
Disables the automatic sorting of the variables list control after each call to AddVariable_V2 is made.

Syntax

SASVaSelObj.BeginMultipleAddVariableCalls ( )

Remarks

Calling BeginMultipleAddVariableCalls indicates that numerous calls to the AddVariable_V2 method are about to take place and that the control should not perform a sort of the variables list control after each new variable is added. Not performing the sort improves the performance of the AddVariable_V2 routine and, for large numbers of variables, vastly reduces the user's wait time until the control is populated and ready to use.

The associated method EndMultipleAddVariableCalls should be called once the calls to the AddVariable_V2 method have been completed, at which time the sorting is reenabled and the variables currently contained within the list control are sorted.

Example

Dim bRC As Boolean
Dim i As Integer

VariableSelector.BeginMultipleAddVariableCalls
For i=1 To 6000
    bRC = VariableSelector.AddVariable_V2("Var" & Trim(Str(i)), "Test Var" & Str(i), i, 5, 8, "", "", False)
Next i
VariableSelector.EndMultipleAddVariableCalls

See Also

  • EndMultipleAddVariableCalls

DeassignAllVariables Method
Remove all variable assignments from all roles.

Syntax

SASVaSelObj.DeassignAllVariables ( )

Returns

TRUE if successful or FALSE if an error condition occurred.

Example

Dim bRC As Boolean

bRC = VariableSelector.DeassignAllVariables()

See Also

  • AssignVariable

  • DeassignVariable

DeassignVariable Method
Remove a variable assignment from a role.

Syntax

SASVaSelObj.DeassignVariable (variable, role)

Parameters

variable
Required. A string value specifying the name of the variable to be deassigned.

role
Required. A string value specifying the name of the role from which the variable is to be deassigned.

Returns

TRUE if successful or FALSE if an error condition occurred.

Example

Dim bRC As Boolean

bRC = VariableSelector.DeassignVariable("SalesYTD", "Columns to print")

See Also

  • AssignVariable

  • DeassignAllVariables

DeselectListView Method
Remove all selections from items within the list of variables.

Syntax

SASVaSelObj.DeselectListView ( )

Example

VariableSelector.DeselectListView

EndMultipleAddVariableCalls Method
Reenables the automatic sorting of the variables list control after each call to AddVariable_V2 is made.

Syntax

SASVaSelObj.EndMultipleAddVariableCalls ( )

Remarks

Calling EndMultipleAddVariableCalls reenables the sorting of the items within the variables list control which was previously disabled by calling BeginMultipleAddVariableCalls. Not performing the sort improves the performance of the AddVariable_V2 routine and for large numbers of variables vastly reduces the user's wait time until the control is populated and ready to use.

Example

Dim bRC As Boolean
Dim i As Integer

VariableSelector.BeginMultipleAddVariableCalls
For i=1 To 6000
    bRC = VariableSelector.AddVariable_V2("Var" & Trim(Str(i)), "Test Var" & Str(i), i, 5, 8, "", "", False)
Next i
VariableSelector.EndMultipleAddVariableCalls

See Also

  • BeginMultipleAddVariableCalls

GetAssignedVar Method
Returns the name of the variable at the specified index position within the list of those variables assigned to a role.

Syntax

SASVaSelObj.GetAssignedVar (role, index)

Parameters

role
Required. A string value specifying the name of the role.
index
Required. An integer value specifying the zero-based index number of the assigned variable the name is required of.

Returns

A string value containing the name of the assigned variable at position index. An empty ("") returned string value indicates that either the specified role does not exist, or that the value of index is out of range.

Remarks

This method is used in conjunction with the method GetNumberAssignedVars, which may be used to determine how many variables are currently assigned a role.

Example

Dim nCount As Integer
Dim nIndex As Integer
Dim strVarName As String

nCount = VariableSelector.GetNumberAssignedVars("Columns to print")
nIndex = 0
While nIndex < nCount
    strVarName = VariableSelector.GetAssignedVar("Columns to print", nIndex)
    .
    .
    .
    nIndex = nIndex + 1
Wend

See Also

  • GetAssignedVarIndex

GetAssignedVarIndex Method
Returns the zero-based index position of a variable within a role's list of assigned variables.

Syntax

SASVaSelObj.GetAssignedVarIndex (variable, role)

Parameters

variable
Required. A string value specifying the name of the variable whose index number is to be located.

role
Required. A string value specifying the name of the role whose assigned variables are to be searched.

Returns

The index number of the specified variable. A returned value of -1 indicates that there was an error while attempting to locate the specified variable.

Example

Dim nIndex As Integer

nIndex = VariableSelector.GetAssignedVarIndex("SalesYTD", "Columns to print")

See Also

  • GetAssignedVar

GetFirstRole Method
Returns an internal key which references the first role within the control.

Syntax

SASVaSelObj.GetFirstRole ( )

Parameters

Returns

A long value is returned which is an internal key referencing the first of the roles defined to the control.

Remarks

The returned value is used as input to the GetNextRole method to begin the enumeration of all the roles currently defined.

Example

Dim lPos As Long
Dim strRoleName As String

lPos = VariableSelector.GetFirstRole()
While lPos != 0
    strRoleName = VariableSelector.GetNextRole(lPos)
    .
    .
    .
Wend

See Also

  • GetNextRole

GetFirstSelectedAssignedVar Method
Returns the name of the first selected variable and the name of the role it is assigned to.

Syntax

SASVaSelObj.GetFirstSelectedAssignedVar (variable, role)

Parameters

variable
Required. A string variable into which the name of the first selected assigned variable is returned.

role
Required. A string variable into which the name of the role the first selected assigned variable has been assigned to.

Returns

TRUE if successful. FALSE if an error condition occurred or there are no selected assigned variables.

Remarks

Subsequent selected assigned variables may be obtained by using the method GetNextSelectedAssignedVar.

Example

Dim bRC As Boolean
Dim strVarName as String
Dim strRoleName as String

bRC = VariableSelector.GetFirstSelectedAssignedVar(strVarName, strRoleName)
While bRC != False
    .
    .
    .
    bRC = VariableSelector.GetNextSelectedAssignedVar(strVarName, strRoleName)
Wend

See Also

  • GetNextSelectedAssignedVar

  • GetNumberOfAssignedVarsSelected

GetMessageIndex Method
Retrieves one of the messages waiting as a result of a failed attempt to assign a variable to a role either interactively or by calling the AssignVariable method.

Syntax

SASVaSelObj.GetMessageIndex (index, parameter1, parameter2, parameter3, parameter4)

Parameters

index
Required. An integer value specifying which of the waiting messages is to be retrieved.

parameter1
Required. A string variable into which the first parameter of the message will be returned.

parameter2
Required. A string variable into which the second parameter of the message will be returned.

parameter3
Required. A string variable into which the third parameter of the message will be returned.

parameter4
Required. A string variable into which the fourth parameter of the message will be returned.

Returns

Returns one of the following message numbers. Otherwise -1 is returned if an error condition occurred.

Id | Number | Example Message
MSGCODE_UNDEFINEDMESSAGE | 0 | This is an undefined message. Please contact your SAS Software Representative and report the following: "A message has been added to the SASVaSel CMsgInfo message queue either without specifying the message code or with a message code which is invalid." (A detailed record of the actions taken leading up to this message would also be helpful.)
MSGCODE_DEPENDENCYMISSING | 1 | The column " & parameter1 & " must first be assigned to the role " & parameter3 & " before it may be assigned to the role " & parameter2 & ".
MSGCODE_EXCLUSIVERULEFAILURE | 2 | The column " & parameter1 & " may not be assigned to the roles " & parameter2 & " and " & parameter3 & " at the same time.
MSGCODE_TOOMANYVARSFORROLE | 3 | The column " & parameter1 & " could not be assigned to the role " & parameter2& " as it already has " & parameter3 & " other columns assigned to it. This is the maximum number of columns allowed for this role.
MSGCODE_VARALREADYINUSE | 4 | Any column(s) assigned to the role " & parameter2 & " must not also be assigned to any other role. The column " & parameter1 & " has already been assigned to the role " & parameter3 & ".
MSGCODE_VARTYPEWRONGFORROLE | 5 | Column " & parameter1 &" has a data type of " & parameter3 & " which is incompatible with the data type of " & parameter4 &" for the role " & parameter2 & ". The column could not be assigned.
MSGCODE_VARINROLEALREADY | 6 | Column " & parameter1 & " is already assigned to the role " & parameter2 & ". Duplicated columns within a role are not permitted.
MSGCODE_DEPENDENCYFOUND | 7 | Unable to deassign the column " & parameter1 & " from the role " & parameter2 & " since the role " & parameter3 & " has the same column assigned to it. The column must be deassigned from the role " & parameter3 & " before the deassignment from the role " & parameter2 & " will succeed.

Remarks

The maximum value for index is determined from the value supplied by the MessagesWaiting event.

Example

Private Sub VariableSelector_MessagesWaiting(ByVal lMsgCount As Long)
    Dim nMsgNo As Integer
    Dim strParam1 As String, strParam2 As String
    Dim strParam3 As String, strParam4 As String
    Dim lIndex As Long

    lIndex = 0
    While lIndex < lMsgCount
        nMsgNo = VariableSelector.GetMessageIndex(lIndex, strParam1, strParam2, strParam3, strParam4)
        .
        . Process message and parameters here...
        .
        lIndex = lIndex + 1
    Wend
End Sub

See Also

  • MessagesWaiting

GetNextRole Method
Returns the name of the role referenced by an internal key as well as updating the internal key to point to the next role.

Syntax

SASVaSelObj.GetNextRole (key)

Parameters

key

Required. A long variable which supplies the internal key value of the role to be retrieved and upon return is updated with the internal key value for the next role.

Remarks

When first using this method, supply the internal key value obtained by calling the method GetFirstRole.

Example

Dim lKey As Long
Dim strRoleName As String

lKey = VariableSelector.GetFirstRole()
While lKey != 0
    strRoleName = VariableSelector.GetNextRole(lKey)
    .
    .
    .
Wend

See Also

  • GetFirstRole

GetNextSelectedAssignedVar Method
Returns the name of the next selected assigned variable and the name of the role it is assigned to.

Syntax

SASVaSelObj.GetNextSelectedAssignedVar (variable, role)

Parameters

variable
Required. A string variable into which the name of the next selected assigned variable is returned.

role
Required. A string variable that name of the role of the next selected assigned variable has been assigned to.

Returns

TRUE if successful or FALSE if an error condition occurred.

Remarks

Before calling this method, the associated method, GetFirstSelectedAssignedVar, must have been previously invoked so as to initialize the internal information structures.

Because these methods use a single set of internal information structures, only one enumeration of the selected assigned variables can be in progress at a time.

Example

Dim bRC As Boolean
Dim strVarName as String
Dim strRoleName as String

bRC = VariableSelector.GetFirstSelectedAssignedVar(strVarName, strRoleName)
While bRC != False
    .
    .
    .
    bRC = VariableSelector.GetNextSelectedAssignedVar(strVarName, strRoleName)
Wend

See Also

  • GetFirstSelectedAssignedVar

  • GetNextSelectedAssignedVar

  • GetNumberOfAssignedVarsSelected

GetNumberAssignedVars Method
Returns a count of the number of variables that have been assigned to a role.

Syntax

SASVaSelObj.GetNumberAssignedVars (role)

Parameters

role
Required. A string value specifying the name of the role for which a count of assigned variables is required.

Returns

The count of variables assigned to the role, or -1 if an error condition occurred.

Remarks

This method is used in conjunction with the method GetAssignedVar, which may be used to retrieve the names of all the variables assigned to a role.

Example

Dim nCount As Integer
Dim nIndex As Integer
Dim strVarName As String

nCount = VariableSelector.GetNumberAssignedVars("Columns to print")
nIndex = 0
While nIndex < nCount
    strVarName = VariableSelector.GetAssignedVar("Columns to print", nIndex)
    .
    .
    .
    nIndex = nIndex + 1
Wend

See Also

  • GetAssignedVar

GetNumberOfAssignedVarsSelected Method
Returns the number of assigned variables that are selected as well as a flag to indicate if the selections are across multiple roles.

Syntax

SASVaSelObj.GetNumberOfAssignedVarsSelected (varsfrommultipleroles)

Parameters

varsfrommultipleroles
Required. A Boolean variable which will be set to TRUE if the selections being reported span multiple roles.

Returns

A count of the number of assigned variables that are selected.

Example

Dim nCount As Integer
Dim bMultipleRoles As Boolean

nCount = VariableSelector.GetNumberOfAssignedVarsSelected(bMultipleRoles)

See Also

  • GetFirstSelectedAssignedVar

  • GetNextSelectedAssignedVar

  • GetNumberOfAssignedVarsSelected

GetNumberOfRoles Method
Returns the number of roles currently defined.

Syntax

SASVaSelObj.GetNumberOfRoles ( )

Returns

The number of roles currently defined to the control. Otherwise, -1 if an error condition occurred.

Example

Dim nCount As Integer

nCount = VariableSelector.GetNumberOfRoles()

GetNumberOfVarsListSelections Method
Returns the number of variables currently selected within the variables list.

Syntax

SASVaSelObj.GetNumberOfVarsListSelections ( )

Returns

The number of variables currently selected within the variables list, or -1 if an error condition occurred.

Example

Dim nCount As Integer
Dim nIndex As Integer
Dim strVarName As String

nCount = VariableSelector.GetNumberOfVarsListSelections()
nIndex = 0
While nIndex < nCount
    strVarName = VariableSelector.GetVarsListSelectedItem(nIndex)
    .
    .
    .
    nIndex = nIndex + 1
Wend

See Also

  • GetVarsListSelectedItem

GetRoleProperty Method
Retrieves the current value of various attributes for a role.

Syntax

SASVaSelObj.GetRoleProperty (role, propertyid)

Parameters

role
Required. A string value which specifies the name of the role for which an attribute value is to be retrieved.

propertyid
Required. An integer value which specifies an id associated with the property (attribute) to be retrieved, as defined in the Settings section.

Settings

Valid settings for propertyid are:

Constant Defined in Type Library | Value | Description
ROLEPROP_NAME | 0 | Role name.
ROLEPROP_MAXNUMVARS | 4 | Maximum number of variables that may be assigned to the role.
ROLEPROP_MINNUMVARS | 5 | Minimum number of variables required by the role.
ROLEPROP_SORTED 7 A flag that describes the order of variables assigned to the role. Values are:
0x00
Not sorted

0x11
Ascending name

0x12
Descending name

0x21
Ascending variable type

0x22
Descending variable type

Returns

A variant value is returned, the type of which depends on the value of propertyid. The returned variant type will be VT_ERROR if a non-supported value is used in propertyid.

propertyid Value | Variant Type
ROLEPROP_NAME (0) | String (VT_BSTR)
ROLEPROP_MAXNUMVARS (4) | Integer (VT_I4)
ROLEPROP_MINNUMVARS (5) | Integer (VT_I4)
ROLEPROP_SORTED (7) | Integer (VT_I4)

Remarks

This method is still a work in progress. At this point, only the four role properties listed are supported.

Example

Dim nMaxNumVars As Integer

nMaxNumVars = VariableSelector.GetRoleProperty("Columns to print", 4)

See Also

  • SetRoleProperty

GetShowLabels Method
Retrieves the value that indicates whether labels or names are displayed for columns.

Syntax

SASVaSelObj.GetShowLabels ( )

Returns

The following Boolean values are returned to indicate whether variable names or labels are displayed:

TRUE
Labels

FALSE
Names

Example

Dim bLabelsAreDisplayed As Boolean

bLabelsAreDisplayed = VariableSelector.GetShowLabels()

See Also

  • SetShowLabels

  • ShowLabelsChanged

GetSortByNameAscending Method
Retrieves the current setting that indicates the sequence in which variable names and labels are sorted.

Syntax

SASVaSelObj.GetSortByNameAscending ( )

Returns The following Boolean values are returned to indicate the order in which the variables names and labels are sorted:

TRUE
Ascending

FALSE
Descending

Example

Dim bSortOrder As Boolean

bSortOrder = VariableSelector.GetSortByNameAscending()

See Also

  • SetSortByNameAscending

  • SortByNameAscendingChanged

GetSorted Method
Retrieves the sort type for a variable assigned to a role.

Syntax

SASVaSelObj.GetSorted (variable, role)

Parameters

variable
Required. A string value specifying the variable being queried.

role
Required. A string value specifying the role to which the variable being queried has been assigned.

Returns

An integer value is returned which describes the variable's current sort order indicator. The returned value is -1 if an error condition occurred.

0
Not sorted

1
Ascending

2
Descending

Remarks

The Sorted property of a variable simply modifies the appearance of the variable-type icon associated with the variable within the role tree. It is for information purposes only.

Example

Dim nSortedState As Integer

nSortedState = VariableSelector.GetSorted("SalesId", "Columns to print")

See Also

  • SetSorted

GetSortVarsByName Method
Retrieves the current setting that indicates whether the variables are sorted by name and label or the order within the data source.

Syntax

SASVaSelObj.GetSortVarsByName ( )

Returns

The following Boolean values are returned that indicate the sort order of variable names and labels.

TRUE
Name and label

FALSE
Data set order

Example

Dim bSortedByNameOrLabel As Boolean

bSortedByNameOrLabel = VariableSelector.GetSortVarsByName()

See Also

  • SetSortVarsByName

  • SortVarsByNameChanged

GetVarsFormat Method
Gets the current format for a variable.

Syntax

SASVaSelObj.GetVarsFormat (variable)

Parameters

variable
Required. A string value specifying the name of the variable to retrieve the currently assigned SAS format for.

Returns

Returns a string containing the name of the SAS format currently defined for the variable.

Example

Dim strFormat As String

strFormat = VariableSelector.GetVarsFormat("SalesYTD")

See Also

  • SetVarsFormat

GetVarsListSelectedItem Method
Retrieves the name of a selected variable from the variables list.

Syntax

SASVaSelObj.GetVarsListSelectedItem (index)

Parameters

index
Required. An integer value specifying the index value of the selected variables list item to be returned.

Returns

A string value which is the name of the selected item within the variables list control. An empty string ("") indicates that an error condition occurred.

Remarks

The maximum value for index is determined by calling the method GetNumberOfVarsListSelections.

Example

Dim nCount As Integer
Dim nIndex As Integer
Dim strVarName As String

nCount = VariableSelector.GetNumberOfVarsListSelections()
nIndex = 0
While nIndex < nCount
    strVarName = VariableSelector.GetVarsListSelectedItem(nIndex)
    .
    .
    .
    nIndex = nIndex + 1
Wend

See Also

  • GetNumberOfVarsListSelections

GetVarsTaskLabel Method
Retrieve the current task label for a variable.

Syntax

SASVaSelObj.GetVarsTaskLabel (variable)

Parameters

variable
Required. A string value specifying the name of the variable to retrieve the current label for.

Returns

Returns a string containing the name of the label currently defined for the variable.

Example

Dim strTaskLabel As String

strTaskLabel = VariableSelector.GetVarsTaskLabel("Age")

See Also

  • SetVarsTaskLabel

RemoveAcceptableVar Method
Removes a variable from the list of acceptable variables for a role.

Syntax

SASVaSelObj.RemoveAcceptableVar (role, variable)

Parameters

role
Required. A string value specifying the role that contains the variable within its list of acceptable variables.

variable
Required. A string value specifying the variable to be removed.

Returns

TRUE if successful or FALSE if an error condition occurred.

Example

Dim bRC As Boolean

bRC = VariableSelector.RemoveAcceptableVar("Columns to print", "SalesId")

See Also

  • AddAcceptableVar

  • RemoveAllAcceptableVars

RemoveAllAcceptableVars Method
Removes all variables from the list of acceptable variables for a role.

Syntax

SASVaSelObj.RemoveAllAcceptableVars (role)

Parameters

role
Required. A string value specifying the role which is to have all variables removed from its list of acceptable variables.

Returns

TRUE if successful or FALSE if an error condition occurred.

Example

Dim bRC As Boolean

bRC = VariableSelector.RemoveAllAcceptableVars("Columns to print")

See Also

  • AddAcceptableVar

  • RemoveAcceptableVar

RemoveAllRoleSelections Method
Removes all item selections from all roles.

Syntax

SASVaSelObj.RemoveAllRoleSelections ( )

Returns

Void.

Example

VariableSelector.RemoveAllRoleSelections

See Also

  • GetFirstSelectedAssignedVar

  • GetNextSelectedAssignedVar

  • GetNumberOfAssignedVarsSelected

RemoveAllRoles Method
Remove all role definitions from the control.

Syntax

SASVaSelObj.RemoveAllRoles ( )

Returns

TRUE if successful or FALSE if an error condition occurred.

Remarks

Calling this method causes the control to appear disabled until at least one new role is defined.

Example

Dim bRC As Boolean

bRC = VariableSelector.RemoveAllRoles()

See Also

  • AddRole_V2

  • RemoveAllVariables

  • RemoveRole

RemoveAllVariables Method
Remove all variable definitions from the control.

Syntax

SASVaSelObj.RemoveAllVariables ( )

Returns

TRUE if successful or FALSE if an error condition occurred.

Remarks

Calling this method will cause the control to appear disabled until at least one new variable is defined.

Example

Dim bRC As Boolean

bRC = VariableSelector.RemoveAllVariables()

See Also

  • AddVariable_V2

  • RemoveAllRoles

  • RemoveVariable

RemoveRole Method
Removes a role definition from the control.

Syntax

SASVaSelObj.RemoveRole (role)

Parameters

role
Required. A string value specifying the name of the role to be removed.

Returns

TRUE if successful or FALSE if an error condition occurred.

Example

Dim bRC As Boolean

bRC = VariableSelector.RemoveRole("Sum by")

See Also

  • AddRole_V2

  • RemoveAllRoles

  • RemoveVariable

  • RemoveAllVariables

RemoveVariable Method
Removes a variable definition from the control.

Syntax

SASVaSelObj.RemoveVariable (variable)

Parameters

variable
Required. A string value specifying the name of the variable to be removed.

Returns

TRUE if successful or FALSE if an error condition occurred.

Example

Dim bRC As Boolean

bRC = VariableSelector.RemoveVariable("SalesYTD")

See Also

  • AddVariable_V2

  • RemoveAllRoles

  • RemoveRole

  • RemoveAllVariables

SelectAssignedVar Method
Sets the selection state on a variable within a role.

Syntax

SASVaSelObj.SelectAssignedVar (role, variable)

Parameters

role
Required. A string value specifying the name of the role which contains the variable to be selected.

variable
Required. A string value specifying the name of the variable to be selected.

Returns

TRUE if successful or FALSE if an error condition occurred.

Remarks

The selection state is removed from all other items within the roles' tree control and the specified variable becomes the only selected item within the control.

Example

Dim bRC As Boolean

bRC = VariableSelector.SelectAssignedVar("Sort by", "Age")

See Also

  • RemoveAllRoleSelections

SetDataModelUnknown Method
This method provides a reference to the current SAS server so that the formats currently defined on the server can be determined.

Syntax

SASVaSelObj.SetDataModelUnknown (segdata)

Parameters

segdata
Required. A SEGData pointer referencing the current SAS server.

Returns

TRUE if successful or FALSE if an error condition occurred.

Remarks

The format information is used only if format editing has been enabled for variables.

If format editing is enabled and this method is not called, then a very limited set of basic SAS formats is provided from an internal table. Also, in this scenario, although user-defined format names may be entered, no validation of the existence of the format can be performed.

If format editing is not enabled for any variable, then this method does not need to be called.

Example

Public Application As SEGApplication   ' Initialized by SEGAddIn_Connect

Private Data As SEGData
.
.
.

Private Sub Form1_Load
    Dim bRC As Boolean

    Application.GetActiveData Data

    bRC = VariableSelector.SetDataModelUnknown(Data)
    If bRC = False Then
        MsgBox "SetDataModelUnknown returned an error."
    End If
    .
    .  The addition of roles and variables to the Variable
    .  Selector control takes place here.
    .
End Sub

See Also

  • FormatEnumeration

  • ShouldPropertyEditingBeEnabled

SetRoleProperty Method
Sets the current value of various attributes for a role.

Syntax

SASVaSelObj.SetRoleProperty (role, propertyid, value)

Parameters

role
Required. A string value which specifies the name of the role for which an attribute value is to be set.

propertyid
Required. An integer value which specifies an id associated with the property (attribute) to be set, as defined in Settings.

value
Required. A variant which contains the new value to be assigned to the property.

Settings

Constant Defined in Type Library | Value | Description
ROLEPROP_MINNUMVARS | 5 | Minimum number of variables required by the role.
ROLEPROP_SORTED 7 A flag that describes the order of variables assigned to the role. Values are:
0x00
Not sorted

0x11
Ascending name

0x12
Descending name

0x21
Ascending variable type

0x22
Descending variable type

Values returned within the value parameter are of the following variant types:

propertyid Value | value Variant Type
ROLEPROP_MINNUMVARS (5) | Integer (VT_I4)
ROLEPROP_SORTED (7) | Integer (VT_I4)

Returns

TRUE if successful or FALSE if an error condition occurred.

Remarks

This method is still a work in progress. At this point, only the two role properties listed are supported.

Example

Dim bRC As Boolean

bRC = VariableSelector.SetRoleProperty("Columns to print", 5, 3)

See Also

  • GetRoleProperty

SetShowLabels Method
Changes between displaying columns' names and displaying columns' labels.

Syntax

SASVaSelObj.SetShowLabels (showlabels)

Parameters

showlabels
Required. A Boolean value specifying whether columns' labels (TRUE) or names (FALSE) should be displayed within the list view and tree view components of the control.

Returns

A Boolean value representing the previous state.

Remarks

The default for the control is to display names (FALSE).

Example

Dim bRC As Boolean

bRC = VariableSelector.SetShowLabels(True)

SetSortByNameAscending Method
Manipulates the order in which variables appear within the variables list.

Syntax

SASVaSelObj.SetSortByNameAscending (sortorder)

Parameters

sortorder
Required. A Boolean value specifying whether to display the variables in ascending (TRUE) or descending (FALSE) name/label sequence.

Returns

A Boolean value that represents the previous state.

Remarks

The initial default sort sequence for the control is ascending (TRUE).

Example

Dim bSortedByNameOrLabelAscending As Boolean

bSortedByNameOrLabelAscending = VariableSelector.SetSortByNameAscending(True)

See Also

  • GetSortByNameAscending

  • SortByNameAscendingChanged

SetSorted Method
Sets the sort type for a variable assigned to a role.

Syntax

SASVaSelObj.SetSorted (variable, role, sorttype)

Parameters

variable
Required. A string value specifying the variable being updated.

role
Required. A string value specifying the role to which the variable being updated has been assigned.

sorttype
Required. An integer value specifying the variable's current sort order indicator, as defined in the Settings section.

Settings

Valid settings for sorttype are:

0
Not sorted

1
Ascending

2
Descending

Returns

TRUE if successful or FALSE if an error condition occurred.

Remarks

The Sorted property of a variable simply modifies the appearance of the variable-type icon associated with the variable within the role tree. It is for information purposes only.

Example

Dim bRC As Boolean

bRC = VariableSelector.SetSorted("Group by", "Age, 2)

See Also

  • GetSorted

SetSortVarsByName Method
Manipulates the attribute by which variables are sorted within the variables list.

Syntax

SASVaSelObj.SetSortVarsByName (nameorder)

Parameters

nameorder
Required. A Boolean value specifying whether to display the variables in alphabetical order by name or label (TRUE), or in the order in which the variables appear in the data source (FALSE).

Returns

A Boolean value representing the previous state.

Remarks

The order in which variables appear in the data source is determined by the value specified in the position parameter of the AddVariable_2 method.

The method SetShowLabels is used to switch between displaying variable names and variable labels within the control.

Example

Dim bRC As Boolean

bRC = VariableSelector.SetSortVarsByName(True)

See Also

  • AddVariable_2

  • SetShowLabels

SetVarsFormat Method
Sets the current format for a variable.

Syntax

SASVaSelObj.SetVarsFormat (variable, format)

Parameters

variable
Required. A string value specifying the name of the variable to set the currently assigned SAS format for.

format
Required. A string value specifying a valid SAS format, including any width and decimal place modifiers.

Returns

TRUE if successful or FALSE if an error condition occurred.

Remarks

The format should be of the general form
[ $ ] format-name [ width ] . [ decimals ]
Refer to SAS Language Reference: Dictionary for a complete description of SAS formats.

Example

Dim bRC As Boolean

bRC = VariableSelector.SetVarsFormat("SalesYTD", "DOLLAR12.2")

See Also

  • GetVarsFormat

SetVarsTaskLabel Method
Sets the current task label for a variable.

Syntax

SASVaSelObj.SetVarsTaskLabel (variable, label)

Parameters

variable
Required. A string value specifying the name of the variable to set the current label for.

label
Required. A string value specifying the new label.

Returns

TRUE if successful or FALSE if an error condition occurred.

Remarks

Changing the label for a variable within the Variable Selector control has no effect on the label associated with the variable within the data source.

Example

Dim bRC As Boolean

bRC = VariableSelector.SetVarsTaskLabel("Age", "Age in Years")

See Also

  • GetVarsTaskLabel

SAS Variable Selector Control Events

DeassignmentsFromRolesEnded Event
Occurs when all of the deassignments resulting from the last action have been completed.

Syntax

Private Sub
SASVaSelObj.DeassignmentsFromRolesEnded ( )

Example

Private Sub VariableSelector_DeassignmentsFromRolesEnded()
    ' Perform any actions that depend on the
    ' completion of deassignment operations
    ' here.

End Sub

MessagesWaiting Event
Occurs whenever one or more messages have resulted from variable assignment or deassignment operations.

Syntax

SASVaSelObj.MessagesWaiting (ByVal count As Long)

Parameters

count
A long value that specifies the number of messages that are waiting to be retrieved.

Remarks

Once this event has occurred, the method GetMessageIndex can be used to retrieve the relevant details for each of the messages. Each message describes an error condition that was generated during the last assignment or deassignment operation.

Example

Private Sub VariableSelector_MessagesWaiting(ByVal lMsgCount As Long)
    Dim nMsgNo As Integer
    Dim strParam1 As String, strParam2 As String
    Dim strParam3 As String, strParam4 As String
    Dim lIndex As Long

    lIndex = 0
    While lIndex < lMsgCount
        nMsgNo = VariableSelector.GetMessageIndex(lIndex, strParam1, strParam2, strParam3, strParam4)
        .
        . Process message and parameters here...
        .
        lIndex = lIndex + 1
    Wend
End Sub

See Also

  • GetMessageIndex

RoleDnDActionEnded Event
Occurs when all assignments of variables to a role have completed, either successfully or unsuccessfully.

Syntax

SASVaSelObj.RoleDnDActionEnded (ByVal role As String)

Parameters

role
A string that contains the name of the role on which the assignments were attempted.

Example

Private Sub VariableSelector_RoleDnDActionEnded(ByVal strRole As String)
    Dim nVarCount As Integer

    nVarCount = VariableSelector.GetNumberAssignedVars(strRole)
    MsgBox "The role " & strRole & " now has " & Str(nVarCount) &
           " variables assigned to it."
End Sub

RoleHover Event
Occurs during a drag and drop (DnD) operation to indicate the name of the role that the mouse pointer is currently hovering over.

Syntax

SASVaSelObj.RoleHover (ByVal role As String)

Parameters

role
A string which specifies the role currently under the mouse pointer, or an empty string if there is no role under the mouse pointer.

Example

Private Sub VariableSelector_RoleHover(ByVal strRole As String)
    Dim strStatus AS String

    If strRole = "" Then
        strStatus = ""
    Else
        strStatus = "The mouse pointer is currently over the role " & strRole
    End If

    StatusBar.SimpleText = strStatus
End Sub

RoleVarsSelectionChanged Event
Occurs whenever there has been a change in the selection state of items assigned to one or more roles.

Syntax

SASVaSelObj.RoleVarsSelectionChanged (ByVal count As Long, ByVal flag As Boolean)

Parameters

count
Returns a long which is a count of the total number of variables currently selected within the role tree.

flag
Returns a Boolean which indicates whether the selections are across multiple roles (TRUE) or are contained within a single role.

Example

Private Sub VariableSelector_RoleVarsSelectionChanged(ByVal lCount As Long,
                   ByVal bMultipleRoles As Boolean)
    Dim strWork As String

    If lCount = 0 Then
        strWork = "."
    Else
        If bMultipleRoles Then
            strWork = " spanning more than one role."
        Else
            strWork = " from a single role."
        End If
    End If

    StatusBar.SimpleText = Str(lCount) & " variables are selected" & strWork
End Sub

ShouldPropertyEditingBeEnabled Event
Occurs just before the properties dialog for a variable is displayed in order to determine whether editing of the variable's label or format should be allowed.

Syntax

SASVaSelObj.ShouldPropertyEditingBeEnabled (ByVal variable As String, editlabels As Boolean, editformats As Boolean)

Parameters

variable
Returns a string containing the name of the variable for which the properties dialog is about to be displayed.

editlabels
A Boolean value which specifies whether the label property should be able to be edited (TRUE) or not (FALSE). The default value is FALSE.

editformats
A Boolean value which specifies whether the format property should be able to be edited (TRUE) or not (FALSE). The default value is FALSE.

Example

Private Sub VariableSelector_ShouldPropertyEditingBeEnabled(ByVal strVarName As String, bEditLabels As Boolean, BEditFormats As Boolean)
    If strVarName = "SalesYTD" Then
        bEditFormats = False
    Else
        bEditFormats = True
    End If

    bEditLabels = True
End Sub

See Also

  • VarFormatChanged

  • VarTaskLabelChanged

ShowHourGlass Event
Occurs whenever the control is in a busy state and requires that the consumer's mouse pointer be changed to an hourglass shape. This typically occurs both before and after the Format tab on the variable Properties page enumerates the names of all the available formats on the server, or during variable assignment and deassignment operations.

Syntax

SASVaSelObj.ShowHourGlass (ByVal busy As Boolean)

Parameters

busy
A Boolean value that indicates whether the hourglass pointer should be displayed by the parent window (TRUE), or the normal pointer for the parent window should be restored (FALSE).

Remarks

If the form (window) which contains the Variable Selector control is itself the child of another window, then the container may also have to notify the parent window that its mouse pointer should also be changed.

Example

Private Sub VariableSelector_ShowHourGlass(ByVal bBusy As Boolean)
    If bBusy Then
        Form1.MousePointer = 11    ' Show the hourglass pointer
    Else
        Form1.MousePointer = 0     ' Show the default pointer
    End If
End Sub

ShowLabelsChanged Event
Occurs when the control receives a request to switch from displaying names to displaying labels for columns.

Syntax

SASVaSelObj.ShowLabelsChanged (ByVal showlabels As Boolean)

Parameters

showlabels
A Boolean value that indicates that a change has been made to whether column labels (TRUE) or column names (FALSE) are displayed.

Example

Private Sub VariableSelector_ShowLabelsChanged(ByVal bShowLabels As Boolean)
    If bShowLabels Then
        ' Labels are being displayed for columns
    Else
        ' Names are being displayed for columns
    End If
End Sub

See Also

  • GetShowLabels

  • SetShowLabels

SortByNameAscendingChanged Event
Occurs when the control receives a request to change the order in which column names or labels are displayed.

Syntax

SASVaSelObj.SortByNameAscendingChanged (ByVal sortascending As Boolean)

Parameters

sortascending
A Boolean value that indicates whether column labels or names are sorted in ascending (TRUE) or descending (FALSE) sequence.

Example

Private Sub VariableSelector_SortByNameAscendingChanged(ByVal bSortAscending As Boolean)
    If bSortAscending Then
        ' Labels or names are being sorted in ascending order
    Else
        ' Labels or names are being sorted in descending order
    End If
End Sub

See Also

  • GetSortByNameAscending

  • SetSortByNameAscending

SortVarsByNameChanged Event
Occurs when the control receives a request to switch from displaying names to displaying labels for columns.

Syntax

SASVaSelObj.SortVarsByNameChanged (ByVal sortbynameorlabel As Boolean)

Parameters

sortbynameorlabel
A Boolean value that indicates whether the displayed columns are sorted by labels or names (TRUE), or in the data source order (FALSE).

Example

Private Sub VariableSelector_SortVarsByNameChanged(ByVal bSortByNameOrLabel As Boolean)
    If bSortByNameOrLabel Then
        ' Columns are displayed sorted by labels or names
    Else
        ' Columns are displayed in data source order
    End If
End Sub

See Also

  • GetSortVarsByName

  • SetSortVarsByName

VarFormatChanged Event
Occurs whenever a variable's format has been modified within the properties dialog.

Syntax

SASVaSelObj.VarFormatChanged (ByVal variable As String, ByVal format As String)

Parameters

variable
Returns a string which contains the name of the variable.

format
Returns a string which contains the new format to be associated with the variable.

Remarks

The ShouldPropertyEditingBeEnabled event fired for this variable must have the associated editformat parameter set to TRUE before the VarFormatChanged event will be received.

Example

Private Sub VariableSelector_VarFormatChanged(ByVal strVarName As String, ByVal strFormat As String)
    StatusBar.SimpleText = "The variable " & strVarName & "
            " now has the format " & strFormat & "."
End Sub

See Also

  • ShouldPropertyEditingBeEnabled

  • VarTaskLabelChanged

VariableAssigned Event
Occurs as the result of a variable having been assigned to a role.

Syntax

SASVaSelObj.VariableAssigned (ByVal variable As String, ByVal role As String, ByVal meetsrequirements As Boolean)

Parameters

variable
Returns a string which contains the name of the variable that has been assigned.

role
Returns a string which contains the name of the role the variable is assigned to.

meetsrequirements
Returns a Boolean value which indicates whether all the requirements, such as the minimum number of variables required, have been met for all roles.

Example

Private Sub VariableSelector_VariableAssigned(ByVal strVarName As String, ByVal strRoleName As String, ByVal bMeetsRequirements As Boolean

    OKButton.Enable = bMeetsRequirements

End Sub

See Also

  • VariableDeassigned

VariableDeassigned Event
Occurs as the result of a variable being deassigned from a role.

Syntax

SASVaSelObj.VariableDeassigned (ByVal variable As String, ByVal role As String, ByVal meetsrequirements As Boolean)

Parameters

variable
Returns a string which contains the name of the variable that has been deassigned.

role
Returns a string which contains the name of the role the variable is deassigned from.

meetsrequirements
Returns a Boolean value which indicates whether all the requirements, such as the minimum number of variables required, have been met for all roles.

Example

Private Sub VariableSelector_VariableDeassigned(ByVal strVarName As String, ByVal strRoleName As String, ByVal bMeetsRequirements As Boolean

    OKButton.Enable = bMeetsRequirements

End Sub

See Also

  • VariableAssigned

VariableNotAcceptableToRole Event
Occurs as the result of an attempted assignment of a variable to a role for which the variable is not among the list of acceptable variables.

Syntax

SASVaSelObj.VariableNotAcceptableToRole (ByVal role As String, ByVal variable As String)

Parameters

role
Returns a string that contains the name of the role the assignment was attempted on.

variable
Returns a string that contains the name of the variable that was attempted to be assigned.

Remarks

The methods AddAcceptableVar, RemoveAcceptableVar and RemoveAllAcceptableVars are used to add or remove variable names from a role's list of acceptable variables. However, the VariableNotAcceptableToRole event only occurs if the method AcceptanceChecking has been used to enable the acceptance checking feature for the role.

Example

Private Sub VariableSelector_VariableNotAcceptableToRole(ByVal strRoleName As String, ByVal strVarName As String)

    MsgBox "The variable " & strVarName &
           " could not be assigned to the role " & strRoleName &
           " because it is not among the list of acceptable variables."

End Sub

See Also

  • AddAcceptableVar

  • RemoveAcceptableVar

  • RemoveAllAcceptableVars

  • AcceptanceChecking

VariableSequenceChanged Event
Occurs when the order of one or more variables within a role has changed.

Syntax

SASVaSelObj.VariableSequenceChanged (ByVal variable As String, ByVal role As String, ByVal newposition As Long)

Parameters

variable
Returns a string that contains the name of the variable that has changed position. If the change has affected more than one variable, then an empty ("") string will be returned.

role
Returns a string that contains the name of the role within which the variable has changed position.

newposition
Returns a long value that is the new position of the variable within the list of variables assigned to the role. This value should be ignored if an empty string has been returned for the variable parameter.

Example

Private Sub VariableSelector_VariableSequenceChanged(ByVal strVarName as String, ByVal strRoleName as String, ByVal lNewPos as Long)
    Dim nIndex As Integer
    Dim nCount As Integer
    Dim strWork As String
    Dim strList As String

    nCount = VariableSelector.GetNumberAssignedVars(strRoleName)
    If nCount > 0 Then
        For nIndex = 0 To nCount - 1
            strWork = VariableSelector.GetAssignedVar(strRoleName, nIndex)
            If strWork <> "" Then
                strList = strList & Chr(13) & Chr(10) & strWork
            End If
        Next I

        MsgBox "The following is a list of variables assigned to the role " & strRoleName & ":" & strList
    Else
        MsgBox "No variables are assigned to " & strRoleName
    End If

End Sub

VarsListSelectionChanged Event
Occurs when the selection state of items within the variables list has changed.

Syntax

SASVaSelObj.VarsListSelectionChanged (ByVal selections As Long)

Parameters

selections
Returns a long value which is the count of the number of variables currently selected within the variables list control.

Example

Private Sub VariableSelector_VarsListSelectionChanged(ByVal lNumberOfVarsSelected As Long)
    StatusBar.SimpleText = Str(lNumberOfVarsSelected) & " variables are currently selected."
End Sub

VarTaskLabelChanged Event
Occurs whenever a variable's label has been modified within the properties dialog.

Syntax

SASVaSelObj.VarTaskLabelChanged (ByVal variable As String, ByVal label As String)

Parameters

variable
Returns a string which contains the name of the variable.

label
Returns a string which contains the new label for the variable.

Remarks

The ShouldPropertyEditingBeEnabled event fired for this variable must have the associated editlabel parameter set to TRUE before the VarTaskLabelChanged event will be received.

Example

Private Sub VariableSelector_VarTaskLabelChanged(ByVal strVarName As String, ByVal strLabel As String)
    StatusBar.SimpleText = "The variable " & strVarName & "
            " now has the label " & strLabel & "."
End Sub

See Also

  • ShouldPropertyEditingBeEnabled

  • VarFormatChanged

SAS Color Selector Control

 The SAS Color Selector control provides a means for users to select colors. Three different color palettes are predefined within the control and the user can also define custom colors.

The control can appear as a toolbar button, a combo box of standard (fixed) combo box height, or a varying height combo box, for example, to use as a child of a list control.

An additional option button can also be displayed which can be used for any utility task.

File Name

SASCoSel.OCX

Current Interface Version

3

Current CoClass Name

SASCoSel_V3

Remarks

When passing colors to or retrieving colors from the SAS Color Selector control, although references are made to RGB (red, green, blue) values, the component colors are reversed within hexadecimal constants (blue, green, red). For example, to specify a color where the red component has a value of 255, the green component has a value of 0 and the blue component has a value of 192, the constant would be:

&HC000FF&
in Visual Basic
0xC000FF
in Visual C++

The 'Automatic' color is represented by the constant value:
&HFFFFFFFF&
in Visual Basic
0xFFFFFFFF
in Visual C++

In Visual C++ terms, the color values are COLORREF types.

Properties Overview

Appearance | Changes the appearance of the control between a toolbar style button, combo-box style control and a variable height combo-box control. For use within list controls.
AutomaticColor | Sets the color to be used when displaying the "Automatic" color.
AutomaticLabel | Sets the text to be used for the "Automatic" button.
BackSysColorId | Specifies the color the control should use to paint its background.
BorderStyle | Changes the border drawn around the outside of the control.
ColorWellOnlyOnAltVK_DOWN | Prevents the down arrow key from displaying the color well. Forces the parent to receive the WM_KEYDOWN, WM_KEYUP or WM_CHAR message for the VK_DOWN virtual key.
Enabled | Enables or disables the control.
RegistrySerializationKey | Names a registry key within HKEY_CURRNET_USER where user-defined colors are to be read and stored.
ShowOptionButton | Shows or hides the option (rightmost) button.

Methods Overview

AddCustomPaletteEntry_V2 | Defines a custom color entry.
GetColorSASName | A helper function that returns a SAS color name for the supplied RGB value.
GetCurColor | Returns the color currently selected.
GetCustomPaletteEntry_V2 | Returns the custom defined color at the given index.
GetCustomPaletteCount | Returns the total number of defined custom colors.
GetMaxCustomPaletteEntryCount | Returns the maximum number of custom colors which may be defined.
SetCurColor | Sets the color currently selected.
SetPaletteType | Specifies which of the color palettes to display in the color well (see the PALETTE_TYPE typedef).

Events Overview

ColorButtonPressed | Occurs whenever the color button (the leftmost button) is selected.
ColorSelected | Occurs whenever a new color has been selected.
OptionButtonPressed | Occurs whenever the option button (the rightmost button) is selected.

SAS Color Selector Control Properties

Appearance Property
Changes the appearance of the control.

Syntax

SASCoSelObj.Appearance = value

Parameters

value
An integer value which specifies the style the control is to draw itself in. Refer to the Settings section for a list of the valid style values.

Settings

Valid style values are:

0
STYLE_TOOLBUTTON - A toolbar 3D style button of constant size. This is the default.

1
STYLE_COMBOBOX - A combo box with a height consistent with standard combo boxes.

2
STYLE_LISTCOMBOBOX - A combo box with adjustable height.

Remarks

The enumerated types STYLE_TOOLBUTTON, STYLE_COMBOBOX and STYLE_LISTCOMBOBOX are defined within the control's type library. They are members of the COLORBUTTON_STYLE enumeration.

Example

SASCoSel.Appearance = STYLE_COMBOBOX

AutomaticColor Property
Specifies a RGB color value to be used to represent the automatic color.

Syntax

SASCoSelObj.AutomaticColor = value

Parameters

value
A long value which represents the RGB value of the color to be used when displaying the automatic color.

Remarks

The automatic color is used to represent the default color that is used if no color selection is made.

Example

' Set the automatic color to light red.
SASCoSel.AutomaticColor = &H0000FF&

See Also

  • AutomaticLabel

AutomaticLabel Property
Specifies a label to be displayed in place of the word "Automatic" on the Automatic button within the color well.

Syntax

SASCoSelObj.AutomaticLabel = value

Parameters

value
A string value specifying the text to appear on the Automatic button within the color well.

Remarks

The automatic color is the default color that is used if no color selection is made.

Example

' Set the Automatic button's label to "Default".
SASCoSel.AutomaticLabel = "Default"

See Also

  • AutomaticColor

BackSysColorId Property
Sets the color used by the control to paint its background.

Syntax

SASCoSelObj.BackSysColorId = value

Parameters

value
An integer value specifying a COLOR_* value as is used by the Windows API function GetSysColor(). Refer to the Settings section for a list of some of the more common color values.

Settings

Some common color values are:

1
COLOR_DESKTOP - Desktop color.

4
COLOR_MENU - Background color for menus.

5
COLOR_WINDOW - Background color for an application window's client area.

15
COLOR_BTNFACE - Face color for buttons and other three-dimensional objects. Also the background color for a dialog's client area. This is the default.

Remarks

Specifying the same color as the parent's background color blends the control's child windows with the parent's other child windows.

Example

SASCoSel.BackSysColorId = 5     '  COLOR_WINDOW

BorderStyle Property
Specifies style of border to be drawn around the control.

Syntax

SASCoSelObj.BorderStyle = value

Parameters

value
BORDERSTYLE_NONE - The control will not have a border.

Settings

Valid border style values are:

0
BORDERSTYLE_NONE - The control will not have a border.

1
BORDERSTYLE_SINGLE - The control will have a single line as the border.

2
BORDERSTYLE_3D - The control will have a border with a 3D appearance. This is the default.

Remarks

The enumerated types BORDERSTYLE_NONE, BORDERSTYLE_SINGLE and BORDERSTYLE_3D are defined within the control's type library. They are members of the COLORBUTTON_BORDERSTYLE enumeration.

Note that the border style setting only applies when the control is set to STYLE_COMBOBOX or STYLE_LISTCOMBOBOX. It has no effect if the Appearance property is set to STYLE_TOOLBUTTON.

Example

' Set the border style to a single line.
SASCoSel.BorderStyle = BORDERSTYLE_SINGLE

' Set the control style to a combo box.
SASCoSel.Appearance = STYLE_COMBOBOX

See Also

  • Appearance

ColorWellOnlyOnAltVK_DOWN Property
Instructs the control whether to display the color well only if the Alt-down arrow key combination is pressed, ignoring the unmodified down arrow key presses.

Syntax

SASCoSelObj.ColorWellOnlyOnAltVK_DOWN = value

Parameters

value
A Boolean value which specifies whether to ignore unmodified down arrow key presses (TRUE) or to display the color well if the unmodified down arrow key is pressed (FALSE - default).

Remarks

By default both the down arrow key (VK_DOWN) and Alt-down arrow key combination cause the color well to be displayed. However, there are instances where the consumer of the control (a list control for instance) may want the down arrow key notifications for its own purposes. Setting this property to TRUE will redirect the down arrow key-related WM_KEYDOWN, WM_KEYUP and WM_CHAR messages to the control's consumer.

Example

SASCoSel.ColorWellOnlyOnAltVK_DOWN = True

Enabled Property
Enables or disables the entire ActiveX control.

Syntax

SASCoSelObj.Enabled = value

Parameters

value
A Boolean value which specifies whether to enable (TRUE) or disable (FALSE) the control. The default is TRUE.

Example

SASCoSel.Enabled = False

RegistrySerializationKey Property
Enables automatic serialization of custom color information between instances of the Color Selector control.

Syntax

SASCoSelObj.RegistrySerializationKey = value

Parameters

value
A string value for the key within the registry's HKEY_CURRENT_USER hive, from which the custom color definitions are retrieved and stored.

Remarks

Setting this property allows a user's custom defined colors to be automatically accessible between instances of the Color Selector control. At any time the property can be set to an empty string (""), which will stop the automatic serialization from taking place from that point on.

For custom colors defined programmatically using the AddCustomPaletteEntry_V2 method, if a name is supplied for the custom color, then that too will be serialized.

Example

' Store and retrieve custom colors in HKEY_CURRENT_USER\MyApp\Main Dialog
SASCoSel.RegistrySerializationKey = "MyApp\Main Dialog"

See Also

  • AddCustomPaletteEntry_V2

ShowOptionButton Property
Shows or hides the option (rightmost) button.

Syntax

SASCoSelObj.ShowOptionButton = value

Parameters

value
A Boolean value specifying whether to show (TRUE) the option button or to hide it (FALSE). The default is FALSE.

Remarks

The option button is the third and rightmost button on the control. It displays a right-pointing triangle to indicate that pressing it will display a pop-up window or dialog. When it is pressed, the event OptionButtonPressed is fired.

Example

Private Sub Form_Load()
    SASCoSel.ShowOptionButton = True
End Sub

Private Sub SASCoSel_OptionButtonPressed(ByVal lTopLeftX As Long, ByVal lTopLeftY As Long)

    MsgBox "The option button has been pressed."

End Sub

See Also

  • OptionButtonPressed

SAS Color Selector Control Methods

AddCustomPaletteEntry_V2 Method
Adds a custom color to the palette of custom colors.

Syntax

SASCoSelObj.AddCustomPaletteEntry_V2 (color, name)

Parameters

color
Required. A long (COLORREF) value specifying the RGB value for the custom color being defined.

name
Required. A string value specifying the name of color.

Remarks

If no name is supplied for the custom color (the name parameter is equal to ""), then the default string displayed in place of the color name is "Custom Color [Red=999, Green=999, Blue=999]", where the 999 is replaced with the component color values.

Should more custom colors be defined than will fit within the custom palette section of the color well, then the first defined colors are dropped from the palette. The total number of custom colors that can be displayed within the custom palette can be determined by calling the method GetMaxCustomPaletteEntryCount.

Example

VariableSelector.AddCustomPaletteEntry_V2(&H90A8F0&, "Baby Blue")

See Also

  • GetCustomPaletteEntry_V2

  • GetCustomPaletteCount

  • GetMaxCustomPaletteEntryCount

  • RegistrySerializationKey

GetColorSASName Method
A helper function that returns a SAS color name for a given RGB value.

Syntax

SASCoSelObj.GetColorSASName (RGBvalue)

Parameters

RGBvalue
Required. A long (COLORREF) value specifying the RGB value to be returned as as SAS color name.

Returns

A string value which either has the equivalent SAS color name for the supplied RGB value or a SAS color constant string of the form "CXrrggbb" where rr, gg and bb are the two-digit hexadecimal representations of the red, green and blue components of the RGBvalue parameter.

If the RGBvalue equals 0xFFFFFFFF (the Automatic color) then an empty string ("") is returned.

Remarks

This method has no effect on the control whatsoever. It is a helper function to assist the consumer in converting RGB values to SAS color names ready for insertion into SAS code.

Example

Dim strSASName As String

' Should return the SAS color name "STEEL"
strSASName = VariableSelector.GetColorSASName(&H99CCFF&)

GetCurColor Method
Returns information about the currently selected color.

Syntax

SASCoSelObj.GetCurColor (name)

Parameters

name
Required. A string variable in which the SAS name of the currently selected color is returned.

Returns

A long (COLORREF) value which specifies the currently selected color's RGB value.

Example

Dim rgbColor As Long
Dim strName As String

rgbColor = SASCoSel.GetCurColor(strName)

See Also

  • SetCurColor

GetCustomPaletteEntry_V2 Method
Returns information about the custom color at a particular index position within the custom color palette.

Syntax

SASCoSelObj.GetCustomPaletteEntry_V2 (index, name)

Parameters

index
Required. An integer value specifying the index position within the custom color palette of the entry to be returned.

name
Required. A string variable in which the SAS name of the custom color is returned.

Returns

A long (COLORREF) value which specifies the custom color's RGB value.

Remarks

The total number of custom palette entries can be determined by calling the GetCustomPaletteCount method.

This method is usually used for manually serializing the custom palette entries to a file etc. Otherwise the RegistrySerializationKey property can be used to provide automatic serialization of the custom palette to the registry.

Example

Dim nIndex As Integer
Dim nCount As Integer
Dim rgbColor As Long
Dim strName As String

nCount = SASCoSel.GetCustomPaletteCount()
nIndex = 0
While nIndex < nCount
    rgbColor = SASCoSel.GetCustomPaletteEntry_V2(nIndex, strName)
    .
    . The custom palette entry can be stored here ...
    .
    nIndex = nIndex + 1
Wend

See Also

  • GetCustomPaletteCount

  • RegistrySerializationKey

GetCustomPaletteCount Method
Retrieves a count of the number of custom colors currently defined.

Syntax

SASCoSelObj.GetCustomPaletteCount ( )

Returns

An integer value which is a count of the number of custom palette entries currently defined.

Example

Dim nIndex As Integer
Dim nCount As Integer
Dim rgbColor As Long
Dim strName As String

nCount = SASCoSel.GetCustomPaletteCount()
nIndex = 0
While nIndex < nCount
    rgbColor = SASCoSel.GetCustomPaletteEntry_V2(nIndex, strName)
    .
    . The custom palette entry can be stored here ...
    .
    nIndex = nIndex + 1
Wend

See Also

  • GetCustomPaletteEntry_V2

GetMaxCustomPaletteEntryCount Method
Returns the maximum number of custom colors that may be defined at any one time.

Syntax

SASCoSelObj.GetMaxCustomPaletteEntryCount ( )

Returns

An integer value which is a count of the maximum number of custom colors that can be defined within the custom color palette.

Remarks

When the maximum number of custom colors have been defined, the next custom color defined replaces the oldest of the custom palette entries.

Example

Dim nCount As Integer

nCount = SASCoSel.GetMaxCustomPaletteEntryCount()

See Also

  • AddCustomPaletteEntry_V2

  • GetCustomPaletteEntry_V2

SetCurColor Method
Defines which color is currently selected within the control.

Syntax

SASCoSelObj.SetCurColor (RGBvalue)

Parameters

RGBvalue
Required. A long (COLORREF) value specifying the RGB value to be selected within the control.

Remarks

If the color defined by the specified RGBvalue parameter does not exist in either the main color palette or the custom color palette, then the color is added to the custom color palette and is selected from there.

Example

' Select the 'Automatic' color.
VariableSelector.SetCurColor(&HFFFFFFFF&)

See Also

  • GetCurColor

SetPaletteType Method
Sets the type of palette to be displayed within the predefined color palette section of the color well.

Syntax

SASCoSelObj.SetPaletteType (type)

Parameters

type
Required. An integer value specifying the type id for the palette to be displayed, as defined in the Settings section.

Settings

Valid type values are:

0
PALETTE_TYPE_SAS - Predefined SAS colors. This is the default.

1
PALETTE_TYPE_HTML - Standard named HTML colors.

2
PALETTE_TYPE_WINDOWS - Standard named colors that appear within the common Windows color dialog.

Returns

TRUE if the palette was changed successfully, otherwise it returns FALSE.

Remarks

The enumerated types PALETTE_TYPE_SAS, PALETTE_TYPE_HTML and PALETTE_TYPE_WINDOWS are defined within the control's type library. They are members of the PALETTE_TYPE enumeration.

Example

Dim bRC As Boolean
bRC = SASCoSel.SetPaletteType(PALETTE_TYPE_WINDOWS)

SAS Color Selector Control Events

ColorButtonPressed Event
Occurs whenever the color button is pressed.

Syntax

Private Sub SASCoSelObj.ColorButtonPressed ( )

Remarks

This event is only fired if the style of the control is set to STYLE_TOOLBUTTON.

It may be used to implement an apply to selection type of functionality.

Example

Private Sub SASCoSel_ColorButtonPressed()
    ' Perform any actions that depend on the
    ' color button being pressed.

End Sub

See Also

  • Appearance

ColorSelected Event
Occurs whenever a new color has been selected from the color well.

Syntax

SASCoSelObj.ColorSelected (ByVal RGBvalue As Long, ByVal name As String)

Parameters

RGBvalue
An integer value that contains the RGB (COLORREF) value of the color that has just been selected.

name
A string value which either has the equivalent SAS color name for the newly selected color or a SAS color constant string of the form CXrrggbb where rr, gg and bb are the two-digit hexadecimal representations of the red, green and blue components of the RGBvalue parameter.

Example

Private Sub SASCoSel_ColorSelected(ByVal rgbColor As Long, ByVal strName As String)
    If rgbColor = &HFFFFFFFF& Then
        Label.ForeColor = &H0&    ' Make Automatic equate to black
    Else
        Label.ForeColor = rgbColor
    End If
End Sub

OptionButtonPressed Event
Occurs when the option (rightmost) button is pressed.

Syntax

SASCoSelObj.OptionButtonPressed (ByVal topleftx As Long, ByVal toplefty As Long)

Parameters

topleftx
A long value that specifies the X coordinate at which to position the top left corner of a dialog box (or other window) to have it appear "popped out" from the option button.

toplefty
A long value that specifies the Y coordinate at which to position the top left corner of a dialog box (or other window) to have it appear "popped out" from the option button.

Remarks

This event is only received if the ShowOptionButton property has been set to TRUE.

Example

Private Sub Form_Load()
    SASCoSel.ShowOptionButton = True
End Sub

Private Sub SASCoSel_OptionButtonPressed(ByVal lTopLeftX As Long, ByVal lTopLeftY As Long)
    Load Dialog
    Dialog.Label.Caption = "The option button was pressed."
    Dialog.Top = Screen.TwipsPerPixelY * lTopLeftY
    Dialog.Left = Screen.TwipsPerPixelX * lTopLeftX
    Dialog.Show 1
    Unload Dialog
End Sub

See Also

  • ShowOptionButton

SAS Properties Control

 The SAS Properties control provides a means for users to assign values to various properties or attributes.

File Name

SASProps.OCX

Current Interface Version

3

Current CoClass Name

SASProps_V3

Properties Overview

ColumnSplitPercentage | The percentage of the control's width that the first column occupies.
Enabled | Enables or disables the control.
MultipleCategories | Enables multiple categories so that the properties can be grouped when displayed.

Methods Overview

AddCategory | Adds a new category when in multiple category mode.
AddProperty | Adds a new property to a category.
AddPropertyListItem | Adds a new item to a PROPTYPE_COMBOLIST type property's list of items.
ClearAllItems | Removes all category and property definitions from the control.
EnableProperty | Enables or disables an individual property.
GetPropertyListItem | Returns a list item's text value from a PROPTYPE_COMBOLIST type property.
GetPropertyValue | Returns the current value for a property.
IsPropertyEnabled | Determines whether an individual property item is enabled.
SetEditedProperty | Sets a property item as the current one being edited.
SetPropertyButtonTips | Sets tooltip text for buttons on PROPTYPE_DATATABLE and PROPTYPE_DIALOGBTN properties.
SetPropertyMaxNumChars | Sets the maximum number of characters a property value may contain.
SetPropertyMaxValue | Sets the maximum value acceptable by a property.
SetPropertyMinValue | Sets the minimum value acceptable by a property.
SetPropertyValue | Sets the current value or selection within a list for a property.

Events Overview

ComboListHidden | Occurs when the combo list for an item is hidden.
ComboListVisible | Occurs as soon as the combo list for an item is displayed.
DialogButtonSelected | Occurs when a PROPTYPE_DIALOGBTN item's ... pushbutton is pressed.
EditingPropertyValue | Occurs when the editing of a property value begins.
PropertyValueChanged | Occurs when a change the value of a property has changed.
ResetButtonSelected | Occurs when a PROPTYPE_DATATABLE item's reset pushbutton is pressed.
ValidateValue | Occurs to give the consumer the ability to reject a modified value.

SAS Properties Control Properties

ControlSplitPercentage Property
Specifies the percentage of the control's width that is to be taken up by the list control's first column.

Syntax

SASPropsObj.ControlSplitPercentage = value

Parameters

value
An integer value between 15 and 85 (inclusive) which specifies the percentage of the control's width to be taken up by the first column of the list control. The default value is 50, which gives a 50/50 split.

Example

SASProps.ControlSplitPercentage = 33    ' Changes the split to 33/67

Enabled Property
Enables or disables the entire ActiveX control.

Syntax

SASPropsObj.Enabled = value

Parameters

value
A Boolean value which specifies whether to enable (TRUE) or disable (FALSE) the control. TRUE is the default.

Example

SASProps.Enabled = False

MultipleCategories Property
Allows properties to be visually grouped into expandable and contractible categories.

Syntax

SASPropsObj.MultipleCategories = value

Parameters

value
A Boolean value which either enables (TRUE) or disables (FALSE) the categorization of properties. TRUE is the default.

Remarks

This property can only be changed if there are no categories or properties assigned to the control. The method ClearAllItems can be used to ensure nothing is defined to the control before changing the MultipleCategories property.

Example

SASProps.MultipleCategories = False

See Also

  • AddCategory

  • AddProperty

  • ClearAllItems

SAS Properties Control Methods

AddCategory Method
Adds a new category.

Syntax

SASPropsObj.AddCategory (name)

Parameters

name
Required. A string value specifying the name of the new category.

Returns

A long integer value which is an identifier for the newly added category. If an error occurs, a value of -1 is returned.

Remarks

Before the AddCategory method can be used, the MultipleCategories property must have been set to TRUE.

The returned value is used in all subsequent references to the newly added category. For instance, when the AddProperty method is called, the category identifier is used to specify the category under which the new property is to be added.

Example

Dim lGenCatId As Long
Dim lAdvCatId As Long
Dim lLPPPropId as Long
Dim lSObsPropId as Long
Dim lEObsPropId as Long

SASProps.MultipleCategories = True
lCatId = SASProps.AddCategory("General")
lLPPPropId = SASProps.AddProperty("Lines per page", lGenCatId, PROPTYPE_INTEDIT)
lCatId = SASProps.AddCategory("Advanced")
lSObsPropId = SASProps.AddProperty("Start obs", lAdvCatId, PROPTYPE_INTEDIT)
lEObsPropId = SASProps.AddProperty("End obs", lAdvCatId, PROPTYPE_INTEDIT)

See Also

  • AddProperty

  • MultipleCategories

AddProperty Method
Adds a new property.

Syntax

SASPropsObj.AddProperty (name, category, type)

Parameters

name
Required. A string value specifying the display name of the new property.

category
Required. A long value specifying the category id of the category under which the new property is to be added.

type
Required. An integer value specifying the type of property, as defined in the Settings section.

Settings

Valid settings for type are:

1
PROPTYPE_TEXTEDIT - Text string

2
PROPTYPE_INTEDIT - Integer value.

3
PROPTYPE_FLOATEDIT - Floating-point value.

4
PROPTYPE_COMBOLIST - Combo box drop-down list.

6
PROPTYPE_DIALOGBTN - ... button to display a secondary dialog.

7
PROPTYPE_DATATABLE - ... and reset buttons for selection and resetting data table names.

9
PROPTYPE_INTLISTEDIT - A list of integer values and/or integer ranges separated by commas.

Returns

A long integer value which is an identifier for the newly added property. If an error occurs, a value of -1 is returned.

Remarks

The returned value is used in all subsequent references to the newly added property. For example, when determining the current value of a property, the property id of the property to be queried is supplied as a parameter to the method GetPropertyValue.

The enumerated types PROPTYPE_TEXTEDIT, PROPTYPE_INTEDIT, PROPTYPE_FLOATEDIT, PROPTYPE_COMBOLIST, PROPTYPE_DIALOGBTN, PROPTYPE_DATATABLE and PROPTYPE_INTLISTEDIT are defined within the control's type library. They are members of the PROPTYPE enumeration.

The value for the parameter category is ignored if the property MultipleCategories is set to FALSE.

Example

Dim lCatId As Long
Dim lPropId as Long

SASProps.MultipleCategories = True
lCatId = SASProps.AddCategory("General")
lPropId = SASProps.AddProperty("Lines per page", lCatId, PROPTYPE_INTEDIT)

See Also

  • AddCategory

  • MultipleCategories

AddPropertyListItem Method
Adds a new list item to a PROPTYPE_COMBOLIST type property.

Syntax

SASPropsObj.AddPropertyListItem (property, listitem)

Parameters

property
Required. A long value specifying the id of the PROPTYPE_COMBOLIST type property to which the list item is to be added.

listitem
Required. A string value specifying the text for the list item being added.

Returns

TRUE if the list item is added, FALSE if there is an error.

Remarks

The list items are always appended to the end of the current list items for the property.

Example

Private Sub Form_Load()
    Dim lCatId As Long
    Dim lPropId As Long

    lCatId = SASProps.AddCategory("General")
    lPropId = SASProps.AddProperty("Show output", lCatId, PROPTYPE_COMBOLIST)
    SASProps.AddPropertyListItem lPropId, "True"
    SASProps.AddPropertyListItem lPropId, "False"
    SASProps.SetPropertyValue lPropId, 0
End Sub

See Also

  • GetPropertyListItem

AllPropertyValuesAreValidated Method
Determines whether all of the property values are valid.

Syntax

SASPropsObj.AllPropertyValuesAreValidated ( )

Returns

TRUE if all of the property values are valid or FALSE if the property currently being edited is not valid.

Remarks

This method should primarily be used within the termination routine of the consuming dialog to check whether the value currently being edited is valid. If it is not valid, then the dialog termination should be aborted and focus be set back onto the property control.

Example

Private lCCodeProp As Long

Private Sub Form_Load()
    SASProps.MultipleCategories = False
    lCCodeProp = SASProps.AddProperty("Country code", 0, PROPTYPE_INTEDIT)
    SASProps.SetPropertyValue lCCodeProp, "64"
End Sub

Private Sub Form_QueryUnload(Cancel As Integer, UnloadMode As Integer)
    If SASProps.AllPropertyValuesAreValidated Then
        Cancel = False
    Else
        Cancel = True
    End If
End Sub

Private Sub SASProps_ValidateValue(ByVal lPropId As Long, ByVal strValue As String, bValueOK As Boolean)
    Dim nCountryCode As Integer

    If lPropId = lCCodeProp Then
        nCountryCode = Val(strValue)
        Select Case nCountryCode
            ' Check for international telephone country codes for United
            ' States & Canada, United Kingdom, Australia and New Zealand.
            Case 1, 44, 61, 64
                bValueOK = True
            Case Else
                MsgBox "Invalid telephone country code entered."
                bValueOK = False
        End Select
    End If
End Sub

See Also

  • ValidateValue

ClearAllItems Method
Removes all categories and properties.

Syntax

SASPropsObj.ClearAllItems ( )

Example

SASProps.ClearAllItems

EnableProperty Method
Enables or disables an individual property.

Syntax

SASPropsObj.EnableProperty (property, enable)

Parameters

property
Required. A long value specifying the id of the property whose state will be changed.

enable
Required. A Boolean value specifying whether the property should be enabled (TRUE) or disabled (FALSE).

Returns

TRUE if the properties state was updated, FALSE if there was an error.

Example

Dim lCatId As Long
Dim lPropId as Long

SASProps.MultipleCategories = True
lCatId = SASProps.AddCategory("General")
lPropId = SASProps.AddProperty("Lines per page", lCatId, PROPTYPE_INTEDIT)
SASProps.EnableProperty(lPropId, False)

See Also

  • IsPropertyEnabled

GetPropertyListItem Method
Returns the maximum number of custom colors that may be defined at any one time.

Syntax

SASPropsObj.GetPropertyListItem (property, index)

Parameters

property
Required. A long value specifying the id of the PROPTYPE_COMBOLIST type property to retrieve the list item from.

index
Required. An integer value specifying the zero-based index of the list item to be returned.

Returns

The list item's text string.

Example

Private g_lPropId As Long

Private Sub Form_Load()
    Dim lCatId As Long

    lCatId = SASProps.AddCategory("General")
    g_lPropId = SASProps.AddProperty("Show output", lCatId, PROPTYPE_COMBOLIST)
    SASProps.AddPropertyListItem g_lPropId, "True"
    SASProps.AddPropertyListItem g_lPropId, "False"
    SASProps.SetPropertyValue g_lPropId, 0
End Sub

Private Sub SASProps_PropertyValueChanged(ByVal lPropId As Long, ByVal vNewPropValue As Variant)
    Dim strValue As String

    If g_lPropId = lPropId Then
        strValue = SASProps.GetPropertyListItem(lPropId, vNewPropValue)
        MsgBox "Item selected is " & Str(vNewPropValue) & " (" & strValue & ")"
    End If
End Sub

See Also

  • AddPropertyListItem

GetPropertyValue Method
Returns the current value for a property.

Syntax

SASPropsObj.GetPropertyValue (property)

Parameters

property
Required. A long value specifying the id of the property to retrieve the current value for.

Returns

The returned variant type will be VT_ERROR if a non-supported value is used in property.

property PROPTYPE | Variant Type | Notes
PROPTYPE_TEXTEDIT (1) | String (VT_BSTR) |
PROPTYPE_INTEDIT (2) | String (VT_BSTR) |
PROPTYPE_FLOATEDIT (3) | String (VT_BSTR) |
PROPTYPE_COMBOLIST (4) | Integer (VT_I4) | Zero-based index of the selected list item.
PROPTYPE_DIALOGBTN (6) | String (VT_BSTR) |
PROPTYPE_DATATABLE (7) | String (VT_BSTR) |
PROPTYPE_INTLISTEDIT (9) | String (VT_BSTR) |

Example

Dim vValue as Variant

vValue = SASProps.GetPropertyValue(lPropId)

See Also

  • AddProperty

  • SetPropertyValue

IsPropertyEnabled Method
Determines whether an individual property item is enabled.

Syntax

SASPropsObj.IsPropertyEnabled (property)

Parameters

property
Required. A long value specifying the id of the property item to be queried for its state.

Returns

TRUE if the property item is enabled, FALSE if it is disabled.

Example

If SASProps.IsPropertyEnabled(lPropId) Then
    .
    .  the property item is currently enabled
    .
End If

See Also

  • EnableProperty

SetEditedProperty Method
Determines whether an individual property item is enabled.

Syntax

SASPropsObj.SetEditedProperty (property)

Parameters

property
Required. A long value specifying the id of the property item to become the currently active item.

Returns

TRUE if the property item is now the current active item, FALSE if an error occurred.

Remarks

Before the property item is activated, the currently active item is validated. If the validation fails, then an error condition (FALSE) is returned and the property item is not activated.

Example

SASProps.SetEditedProperty(lPropId) Then
    .
    .  the property item is currently enabled
    .
End If

SetPropertyButtonTips Method
Sets tooltip text for the pushbuttons associated with PROPTYPE_DATATABLE and PROPTYPE_DIALOGBTN type properties.

Syntax

SASPropsObj.SetPropertyButtonTips (property, dialog, reset)

Parameters

property
Required. A long value specifying the id of the PROPTYPE_DATATABLE or PROPTYPE_DIALOGBTN property item to have its button's tooltip text updated.

Returns

TRUE if the tooltip text is updated for the property item, FALSE if an error condition is encountered.

Remarks

A property of type PROPTYPE_DIALOGBTN only displays a single button, in which case the reset parameter value is ignored.

Example

Dim lCatId As Long
Dim lPropId as Long

SASProps.MultipleCategories = True
lCatId = SASProps.AddCategory("General")
lPropId = SASProps.AddProperty("Output file", lCatId, PROPTYPE_DIALOGBTN)
SASProps.SetPropertyButtonTips(lPropId, "Displays a file selection dialog", "")

SetPropertyMaxNumChars Method
Limits the maximum number of characters that may be entered for a PROPTYPE_TEXTEDIT type property's value.

Syntax

SASPropsObj.SetPropertyMaxNumChars (property, characters)

Parameters

property
Required. A long value specifying the id of the property item whose maximum character length will be changed.

characters
Required. A long value maximum number of characters that may be entered for the property's value.

Returns

TRUE if the size limit was set, FALSE if an error condition occurred.

Remarks

If this method is called on a property item that is not of type PROPTYPE_TEXTEDIT, then an error condition is returned.

Example

Dim lPropId as Long

SASProps.MultipleCategories = False
lPropId = SASProps.AddProperty("Variable Name", 0, PROPTYPE_TEXTEDIT)
SASProps.SetPropertyMaxNumChars(lPropId, 32)

See Also

  • SetPropertyMaxValue

  • SetPropertyMinValue

SetPropertyMaxValue Method
Sets the maximum allowable value for a PROPTYPE_INTEDIT, PROPTYPE_INTLISTEDIT or PROPTYPE_FLOATEDIT type property item.

Syntax

SASPropsObj.SetPropertyMaxValue (property, maximum)

Parameters

property
Required. A long value specifying the id of the property item having its maximum acceptable value set.

maximum
Required. A variant value specifying the maximum allowable value for property. In the case of PROPTYPE_INTEDIT and PROPTYPE_INTLISTEDIT, the variant value must be a Short (VT_I2) or a Long (VT_I4). For PROPTYPE_FLOATEDIT properties, the variant value can be a Short (VT_I2), a Long (VT_I4) or a Double (VT_R8).

Returns

TRUE if the maximum value is set for property, FALSE if there is an error.

Example

Dim lPropId as Long

SASProps.MultipleCategories = False
lPropId = SASProps.AddProperty("Variable Name", 0, PROPTYPE_FLOATEDIT)
SASProps.SetPropertyMinValue(lPropId, -10)
SASProps.SetPropertyMaxValue(lPropId, 10)

See Also

  • SetPropertyMinValue

SetPropertyMinValue Method
Sets the minimum allowable value for a PROPTYPE_INTEDIT, PROPTYPE_INTLISTEDIT or PROPTYPE_FLOATEDIT type property item.

Syntax

SASPropsObj.SetPropertyMinValue (property, minimum)

Parameters

property
Required. A long value specifying the id of the property item having its minimum acceptable value set.

minimum
Required. A variant value specifying the minimum allowable value for property. In the case of PROPTYPE_INTEDIT and PROPTYPE_INTLISTEDIT, the variant value must be a Short (VT_I2) or a Long (VT_I4). For PROPTYPE_FLOATEDIT properties, the variant value can be a Short (VT_I2), a Long (VT_I4) or a Double (VT_R8).

Returns

TRUE if the minimum value has been set for property, FALSE if there has been an error.

Example

Dim lPropId as Long

SASProps.MultipleCategories = False
lPropId = SASProps.AddProperty("Variable Name", 0, PROPTYPE_FLOATEDIT)
SASProps.SetPropertyMinValue(lPropId, -10)
SASProps.SetPropertyMaxValue(lPropId, 10)

See Also

  • SetPropertyMaxValue

SetPropertyValue Method
Sets the current value for a property item.

Syntax

SASPropsObj.SetPropertyValue (property, value)

Parameters

property
Required. A long value specifying the id of the property item having its minimum acceptable value set.

value
Required. A variant value specifying the new value for property. In the case of PROPTYPE_COMBOLIST, the variant value must be a Short (VT_I2) or a Long (VT_I4) representing the index of the combo list item to be selected. For PROPTYPE_INTEDIT and PROPTYPE_FLOATEDIT, the variant value may be of type Short (VT_I2), Long (VT_I4), Double (VT_R8) or String (VT_BSTR). For all other property types, the variant value must be a String (VT_BSTR).

Returns

TRUE if the minimum value is set for property, FALSE if there is an error.

Example

Dim lFloatProp as Long
Dim lIntListProp as Long

SASProps.MultipleCategories = False
lFloatProp = SASProps.AddProperty("Ratio", 0, PROPTYPE_FLOATEDIT)
SASProps.SetPropertyValue lFloatProp, "91.23853E-2"
lIntListProp = SASProps.AddProperty("Page numbers", 0, PROPTYPE_INTLISTEDIT)
SASProps.SetPropertyValue lIntListProp, "1, 3-7, 15, 9"

See Also

  • GetPropertyValue

  • SetPropertyMaxValue

  • SetPropertyMinValue

SAS Properties Control Events

ComboListHidden Event
Occurs whenever the combo list for a PROPTYPE_COMBOLIST property item is hidden.

Syntax

Private Sub SASPropsObj.ComboListHidden (ByVal property As Long, ByVal index As Long)

Parameters

property
A long value that contains the id of the property item.

index
A long value that contains the zero-based index of the list item that is currently selected.

See Also

  • ComboListVisible

ComboListVisible Event
Occurs whenever the combo list for a PROPTYPE_COMBOLIST property item is made visible.

Syntax

Private Sub SASPropsObj.ComboListVisible (ByVal property As Long)

Parameters

property
A long value that contains the id of the property item.

See Also

  • ComboListHidden

DialogButtonSelected Event
Occurs whenever the dialog (...) button is selected on a PROPTYPE_DIALOGBTN or PROPTYPE_DATATABLE property item.

Syntax

SASPropsObj.DialogButtonSelected (ByVal property As Long)

Parameters

property
A long value that contains the id of the property item associated with the dialog button.

Example

Private lDlgBtnProp As Long

Private Sub Form_Load()
    SASProps.MultipleCategories = False
    lDlgBtnProp = SASProps.AddProperty("Column rows", 0, PROPTYPE_DIALOGBTN)
End Sub

Private Sub SASProps_DialogButtonSelected(ByVal lPropId As Long)
    If lPropId = lDlgBtnProp Then
        Load Dialog
        Dialog.strColNames = SASProps.GetPropertyValue(lPropId)
        Dialog.Show 1
        SASProps.SetPropertyValue lPropId, Dialog.strColNames
        Unload Dialog
    End If
End Sub

See Also

  • ResetButtonSelected

EditingPropertyValue Event
Occurs whenever the editing of a property item value first begins.

Syntax

SASPropsObj.EditingPropertyValue (ByVal property As Long)

Parameters

property
A long value that contains the id of the property item being edited.

Remarks

This event is fired for property items of type PROPTYPE_INTEDIT, PROPTYPE_INLISTEDIT, PROPTYPE_FLOATEDIT and PROPTYPE_TEXTEDIT.

PropertyValueChanged Event
Occurs whenever the property value has been changed and successfully validated.

Syntax

SASPropsObj.PropertyValueChanged (ByVal property As Long)

Parameters

property
A long value that contains the id of the property item whose value has changed.

Remarks

This event is typically fired when the Enter key is pressed or an attempt is made to change focus or selection while editing the value.

Example

Private lRYearProp As Long

Private Sub Form_Load()
    SASProps.MultipleCategories = False
    lRYearProp = SASProps.AddProperty("Reporting year", 0, PROPTYPE_INTEDIT)
End Sub

Private Sub SASProps_PropertyValueChanged(ByVal lPropId As Long)
    If lPropId = lRYearProp Then
        MsgBox "New value for the Reporting Year property is " & SASProps.GetPropertyValue(lRYearProp);
        Unload Dialog
    End If
End Sub

See Also

  • GetPropertyValue

ResetButtonSelected Event
Occurs whenever the reset button is selected on a PROPTYPE_DATATABLE property item.

Syntax

SASPropsObj.ResetButtonSelected (ByVal property As Long)

Parameters

property
A long value that contains the id of the property item associated with the reset button.

Example

Public strOriginalValue as String

Private lDataTableProp As Long

Private Sub Form_Load()
    SASProps.MultipleCategories = False
    lDataTableProp = SASProps.AddProperty("Column rows", 0, PROPTYPE_DATATABLE)
    SASProps.SetPropertyValue lDataTableProp, strOriginalValue
End Sub

Private Sub SASProps_DialogButtonSelected(ByVal lPropId As Long)
    If lPropId = lDataTableProp Then
        SASProps.SetPropertyValue lPropId, strOriginalValue
    End If
End Sub

See Also

  • DialogButtonSelected

ValidateValue Event
Occurs when the control has successfully validated a property's value, giving the user the ability to perform additional, external validation and reject the value if necessary.

Syntax

SASPropsObj.ValidateValue (ByVal property As Long, ByVal value As String, OK As Boolean)

Parameters

property
A long value that contains the id of the property item that has had its value validated.

value
A string value that contains the validated value of the property.

OK
A Boolean value that specifies whether the value is acceptable. The default value is TRUE.

Example

Private lCCodeProp As Long

Private Sub Form_Load()
    SASProps.MultipleCategories = False
    lCCodeProp = SASProps.AddProperty("Country code", 0, PROPTYPE_INTEDIT)
    SASProps.SetPropertyValue lCCodeProp, "64"
End Sub

Private Sub Form_QueryUnload(Cancel As Integer, UnloadMode As Integer)
    If SASProps.AllPropertyValuesAreValidated Then
        Cancel = False
    Else
        Cancel = True
    End If
End Sub

Private Sub SASProps_ValidateValue(ByVal lPropId As Long, ByVal strValue As String, bValueOK As Boolean)
    Dim nCountryCode As Integer

    If lPropId = lCCodeProp Then
        nCountryCode = Val(strValue)
        Select Case nCountryCode
            ' Check for international telephone country codes for United
            ' States & Canada, United Kingdom, Australia and New Zealand.
            Case 1, 44, 61, 64
                bValueOK = True
            Case Else
                MsgBox "Invalid telephone country code entered."
                bValueOK = False
        End Select
    End If
End Sub

See Also

  • AllPropertyValuesAreValidated

SAS Option Selector Control

 The SAS Option Selector control provides a means for users to select options and to place the options in a particular order.

File Name

SASOpSel.OCX

Current Interface Version

1

Current CoClass Name

SASOpSel

Properties Overview

BackSysColorId | Specifies the color the control uses to paint its background.
ControlSplitPercentage | The percentage of the control at which the split between the available and selected options lists should be placed.
OptionsTitle | Replaces the default text used as the title for the available options list control.
SelectedOptionsTitle | Replaces the default text used as the title for the Selected Options list control.
ShowReorderButtons | Displays or hides the reordering buttons for the selected options list.

Methods Overview

AddImage | Defines an icon or bitmap image to the control.
AddOption | Defines a new option to the control.
ChangeOptionImage | Changes the image associated with an option.
DeselectAllOptions | Moves all the selected options back to the available options list.
DeselectOption | Deselects an option.
GetSelectedOptionAt | Returns the selected option at the specified zero-based index.
GetSelectedOptionCount | Retrieves the number of options that have been selected.
OptionIsSelected | Tests to see if the specified option has been selected.
RemoveAllOptions | Clears all option definitions from the control.
RemoveOption | Removes an option from the control.
SelectAllOptions | Selects all of the options.
SelectOption | Selects an option.

Events Overview

OptionDeselected | Occurs when an option has been deselected.
OptionSelected | Occurs when an option has been selected.
SelectedOptionHighlighted | Occurs when a selected option is highlighted (selected).
SelectedOptionsSequenceChanged | Occurs when the order of selected options has been changed.

SAS Option Selector Control Properties

BackSysColorId Property
Sets the color used by the control to paint its background.

Syntax

SASOpSelObj.BackSysColorId = value

Parameters

value
An integer value specifying a COLOR_* value as is used by the Windows API function GetSysColor(). Refer to the Settings section for a list of the more common color values.

Settings

Some of the more common settings for value are:

1
COLOR_DESKTOP - Desktop color.

4
COLOR_MENU - Background color for menus.

5
COLOR_WINDOW - Background color for an application window's client area.

15
COLOR_BTNFACE - Face color for buttons and other three-dimensional objects. Also the background color for a dialog's client area. This is the default.

Remarks

Specifying the same color as the parent's background color blends the control's child windows with the parent's other child windows.

Example

SASOpSel.BackSysColorId = 5     '  COLOR_WINDOW

ControlSplitPercentage Property
Specifies the percentage of the control's width that is to be taken up by the Available Options list control.

Syntax

SASVaSelObj.ControlSplitPercentage = value

Parameters

value
An integer value between 15 and 85 inclusive which specifies the percentage of the control's width to be taken up by the Options list control. The default value is 50, which gives a 50/50 split.

Remarks

If the user drags the split to a different position using the UI, the property value is updated to the new percentage value.

Example

SASOpSel.ControlSplitPercentage = 33    ' Changes the split to 33/67

OptionsTitle Property
Replaces the default text used as the title (label) for the Available Options list control.

Syntax

SASOpSelObj.OptionsTitle = value

Parameters

value
A string value which specifies the text to appear in the label associated with the Options list control. If the supplied value does not include a trailing semicolon, one is appended automatically. Specifying an empty string ("") causes the default title to be used.

Example

SASOpSel.OptionsTitle = "Available statistics:"

See Also

  • SelectedOptionsTitle

SelectedOptionsTitle Property
Replaces the default text used as the title (label) for the selected options list control.

Syntax

SASOpSelObj.SelectedOptionsTitle = value

Parameters

value
A string value which specifies the text to appear in the label associated with the Selected Options list control. If the supplied value does not include a trailing semicolon, one is appended automatically. Specifying an empty string ("") causes the default title to be used.

Example

SASOpSel.SelectedOptionsTitle = "Selected statistics:"

See Also

  • OptionsTitle

ShowReorderButtons Property
Displays or hides the reordering buttons for the Selected Options list.

Syntax

SASOpSelObj.ShowReorderButtons = value

Parameters

value
A Boolean value which specifies whether the reordering buttons should be displayed (TRUE) or hidden (FALSE). The default is FALSE.

Remarks

The reordering buttons are used to move highlighted items up or down the Selected Options list control.

Example

SASOpSel.ShowReorderButtons = True

SAS Option Selector Control Methods

AddImage Method
Defines a new icon or bitmap image to the control.

Syntax

SASOpSelObj.AddImage (image, maskcolor, name)

Parameters

image
Required. An IPictureDisp interface obtained from either a StdPicture object in Visual BASIC or a CPictureHolder object in Visual C++.

maskcolor
Required. A long (COLORREF) value specifying the RGB value of the background color used within the image. This parameter only applies to bitmap images and is ignored if the image is an icon.

name
Required. A string value specifying a unique name that this image is referenced by when using the AddOption and ChangeOptionImage methods.

Returns

TRUE if the icon was accepted, FALSE if an error condition occurred.

Remarks

The supplied bitmap or icon MUST be 16 x 16 pixels in size. Images of any other dimensions are rejected.

Example

Visual BASIC

Private Pic1 As StdPicture
Private Pic2 As StdPicture

Private Sub Form_Load()
    Set Pic1 = LoadPicture("IconGood.Bmp")
    Set Pic2 = LoadPicture("IconPoor.Bmp")

    SASOpSel.AddImage Pic1, &HFFFFFF, "Good"
    SASOpSel.AddImage Pic2, &HFFFFFF, "Poor"

    SASOpSel.AddOption 1, "Joe's Diner", "Poor"
    SASOpSel.AddOption 2, "Uppercrust Pies", "Good"
    SASOpSel.AddOption 3, "Biff's Burgers", ""
    SASOpSel.AddOption 4, "Super Snacks", "Good"
End Sub

Visual C++

    CPictureHolder              m_Pic1;
    CPictureHolder              m_Pic2;

    .
    .
    .

    m_Pic1.CreateFromBitmap(IDB_BITMAP_GOOD);
    m_Pic2.CreateFromBitmap(IDB_BITMAP_POOR);

    m_SASOpSel.AddImage(m_Pic1.GetPictureDispatch(), 0xFFFFFF, "Good");
    m_SASOpSel.AddImage(m_Pic2.GetPictureDispatch(), 0xFFFFFF, "Poor");

    m_SASOpSel.AddOption(1, "Joe's Diner", "Poor");
    m_SASOpSel.AddOption(2, "Uppercrust Pies", "Good");
    m_SASOpSel.AddOption(3, "Biff's Burgers", "");
    m_SASOpSel.AddOption(4, "Super Snacks", "Good");

See Also

  • AddOption

  • ChangeOptionImage

AddOption Method
Defines a new option to the control.

Syntax

SASOpSelObj.AddOption (id, text, image)

Parameters

id
Required. A long value specifying an id to be used in subsequent references to this option.

text
Required. A string value specifying the text to be displayed for the item.

image
Required. A string value specifying the name of the image to be displayed as an icon for the item. If no icon is to be associated with the option, an empty string ("") should be supplied.

Returns

TRUE if the icon was accepted, FALSE if an error condition occurred.

Example

Private Pic1 As StdPicture
Private Pic2 As StdPicture

Private Sub Form_Load()
    Set Pic1 = LoadPicture("IconGood.Bmp")
    Set Pic2 = LoadPicture("IconPoor.Bmp")

    SASOpSel.AddImage Pic1, &HFFFFFF, "Good"
    SASOpSel.AddImage Pic2, &HFFFFFF, "Poor"

    SASOpSel.AddOption 1, "Joe's Diner", "Poor"
    SASOpSel.AddOption 2, "Uppercrust Pies", "Good"
    SASOpSel.AddOption 3, "Biff's Burgers", ""
    SASOpSel.AddOption 4, "Super Snacks", "Good"
End Sub

See Also

  • AddImage

ChangeOptionImage Method
Changes the icon displayed for an option.

Syntax

SASOpSelObj.ChangeOptionImage (id, image)

Parameters

id
Required. A long value specifying the id of the option to be modified.

image
Required. A string value specifying the name of the image to be displayed as an icon for the item. If no icon is to be associated with the option, an empty string ("") should be supplied.

Returns

TRUE if successful, FALSE if an error condition occurred.

Example

Private Pic1 As StdPicture
Private Pic2 As StdPicture

Private Sub Form_Load()
    Set Pic1 = LoadPicture("IconGood.Bmp")
    Set Pic2 = LoadPicture("IconPoor.Bmp")

    SASOpSel.AddImage Pic1, &HFFFFFF, "Good"
    SASOpSel.AddImage Pic2, &HFFFFFF, "Poor"

    SASOpSel.AddOption 1, "Joe's Diner", "Poor"
    SASOpSel.AddOption 2, "Uppercrust Pies", "Good"
    SASOpSel.AddOption 3, "Biff's Burgers", ""
    SASOpSel.AddOption 4, "Super Snacks", "Good"
End Sub

Private Sub btnBadRating_Click()
    SASOpSel.ChangeOptionImage 2, "Poor"
End Sub

DeselectAllOptions Method
Moves all selected options back to the available list.

Syntax

SASOpSelObj.DeselectAllOptions ( )

Returns

TRUE if the options were successfully deselected, FALSE if there was an internal error that prevented the options from being deselected.

Example

Dim bRC As Boolean

bRC = SASOpSel.DeselectAllOptions()

See Also

  • DeselectOption

  • SelectAllOptions

  • SelectOption

DeselectOption Method
Moves an option from the list of selected options to the list of available options.

Syntax

SASOpSelObj.DeselectOption (id)

Returns

TRUE if successful, FALSE if an error condition occurred.

Example

Dim bRC As Boolean

bRC = SASOpSel.DeselectOption(3)

See Also

  • DeselectAllOptions

  • SelectAllOptions

  • SelectOption

GetSelectedOptionAt Method
Retrieves the number of options that have been selected.

Syntax

SASOpSelObj.GetSelectedOptionAt (index)

Parameters

index
Required. A long value specifying the zero-based index of the selected option, the id of which is to be returned.

Returns

A long value which is the id of the selected item at the index position.

Example

Dim lIndex As Long
Dim lCount As Long
Dim lOptId As Long

lCount = SASOpSel.GetSelectedOptionCount()
lIndex = 0
While lIndex < lCount
    lOptId = SASOpSel.GetSelectedOptionAt(lIndex)
    .
    .    process the selected option here
    .
WEnd

See Also

  • GetSelectedOptionCount

GetSelectedOptionCount Method
Retrieves the number of options that have been selected.

Syntax

SASOpSelObj.GetSelectedOptionCount ( )

Returns

The total number of options currently selected.

Example

Dim lIndex As Long
Dim lCount As Long
Dim lOptId As Long

lCount = SASOpSel.GetSelectedOptionCount()
lIndex = 0
While lIndex < lCount
    lOptId = SASOpSel.GetSelectedOptionAt(lIndex)
    .
    .    process the selected option here
    .
WEnd

See Also

  • GetSelectedOptionAt

OptionIsSelected Method
Retrieves the number of options that have been selected.

Syntax

SASOpSelObj.OptionIsSelected (id)

Parameters

id
Required. A long value specifying the id of the option to be tested for being selected.

Returns

TRUE if the option is selected, FALSE if it is not.

Example

.
.
.
If SASOpSel.OptionIsSelected(lOptId) Then
    .
    .
    .
End If

RemoveAllOptions Method
Removes all options from the control.

Syntax

SASOpSelObj.RemoveAllOptions ( )

Returns

TRUE if all the options were successfully removed, FALSE if there was an internal error that prevented the options from being removed.

Example

Dim bRC As Boolean

bRC = SASOpSel.RemoveAllOptions()

See Also

  • AddOption

  • RemoveOption

RemoveOption Method
Retrieves the number of options that have been selected.

Syntax

SASOpSelObj.RemoveOption (id)

Parameters

id
Required. A long value specifying the id of the option to be removed from the control.

Returns

TRUE if the option is removed, FALSE if there is an error.

Example

Dim bRC As Boolean

.
.
.
bRC = SASOpSel.RemoveOption(lOptId)

See Also

  • RemoveAllOptions

SelectAllOptions Method
Moves all options from the list of available options to the list of selected options.

Syntax

SASOpSelObj.SelectAllOptions ( )

Returns

TRUE if all of the options are successfully selected, FALSE if there is an error.

Example

Dim bRC As Boolean

bRC = SASOpSel.SelectAllOptions()

See Also

  • DeselectAllOptions

  • DeselectOption

  • SelectOption

SelectOption Method
Moves an option from the list of available options to the list of selected options.

Syntax

SASOpSelObj.SelectOption (id)

Parameters

id
Required. A long value specifying the id of the option to be selected.

Returns

TRUE if the option is selected, FALSE if there is an error.

Example

Dim bRC As Boolean

.
.
.
bRC = SASOpSel.SelectOption(lOptId)

See Also

  • DeselectAllOptions

  • DeselectOption

  • SelectAllOptions

SAS Option Selector Control Events

OptionDeselected Event
Occurs whenever an option has been deselected.

Syntax

SASOpSelObj.OptionDeselected (ByVal id As Long, ByVal index As Long)

Parameters

id
A long value containing the id of the option that has been deselected.

index
A long value containing the zero-based index position at which the option was located within the list of selected options.

Example

Private Sub SASOpSel_OptionDeselected(ByVal dwOptionId As Long, ByVal lIndex as Long)
    MsgBox "The option with id=" & Str(dwOptionId) & " at index position " & Str(lIndex) & " has been deselected."
End Sub

See Also

  • OptionSelected

OptionSelected Event
Occurs whenever an option has been selected.

Syntax

SASOpSelObj.OptionSelected (ByVal id As Long, ByVal index As Long)

Parameters

id
A long value containing the id of the option that has been selected.

index
A long value containing the zero-based index position at which the option was inserted into the list of selected options.

Example

Private Sub SASOpSel_OptionSelected(ByVal dwOptionId As Long, ByVal lIndex as Long)
    MsgBox "The option with id=" & Str(dwOptionId) & " has been selected and inserted into the list of selected options at index position " & Str(lIndex) & "."
End Sub

See Also

  • OptionDeselected

SelectedOptionHighlighted Event
Occurs whenever an option is highlighted (selected).

Syntax

SASOpSelObj.SelectedOptionHighlighted (ByVal id As Long, ByVal index As Long)

Parameters

id
A long value containing the id of the option that has been highlighted.

index
A long value containing the zero-based index position at which the highlighted option is located within the list of selected options.

SelectedOptionsSequenceChanged Event
Occurs whenever the order of a selected option changes.

Syntax

SASOpSelObj.SelectedOptionsSequenceChanged (ByVal id As Long, ByVal index As Long)

Parameters

id
A long value containing the id of the option that has changed position.

index
A long value containing the new zero-based index position at which the option is located within the list of selected options.

SAS Format/Informat Selector Control

 The SAS Format/Informat Selector control provides a means for users to select from both the SAS System and user-defined formats and informats available on a server.

The available formats and informats are grouped within categories such as character, numeric, date, and currency. The user can selectively restrict which categories are displayed, thereby limiting the number of selectable formats.

User-defined formats created with PROC FORMAT are also displayed under a separate category.

File Name

SASFmts.OCX

Current Interface Version

3

Current CoClass Name

SASFmts_V3

Remarks

Although this control relies on a connection to a SAS server to enumerate all of the available formats and informats on the server, there is an internal list of built-in formats and informats that are used if there is no connection. This list consists of those formats and informats which are part of the core SAS System. It does not contain all of the formats or informats provided with the SAS System.

Without a connection to a SAS server, the existence of user-defined formats and informats cannot be validated, although they can be entered at the user's own risk.

For more information on establishing a connection to a SAS server, please refer to the method SetDataAccessorUnknown.

Properties Overview

BackSysColorId | Specifies the color the control uses to paint its background.
Format | The currently selected format or informat.
FormatType | A flag specifying which categories of format or informat should be displayed.
IgnoreInvalidValues | Enables or disables the validation of values entered into the edit subcontrols.

Methods Overview

AllEnteredValuesAreValid | Checks whether all values entered in edit fields are valid.
ChangeNoneToDefault | Changes the text "None" to "Default" within the Categories list control.
MakeNothingSelected | Removes all selections from all of the list controls.
SetDataAccessorUnknown | Supplies the control with a pointer to the SAS Data Accessor's IUnknown interface. Used by the control during format enumeration.
SplitUpFormat | A utility function to split a format name into its component parts.

Events Overview

FormatChangedV3 | Occurs when the format or its properties change.
FormatEnumeration | Occurs when the querying of the server for format information begins or ends.

SAS Format/Informat Selector Control Properties

BackSysColorId Property

Format Property
The name of the currently selected format.

Syntax

SASFmtsObj.Format = value

Parameters

value
A string value specifying the name of the format or informat which is to appear as selected within the control.

Remarks

Value is required to be a SAS format name of the following form:

<$>format.

Refer to SAS Language Reference: Dictionary for a complete description of SAS formats.

If an invalid format name is supplied, an exception is thrown by the control. The exception should be handled with an "On Error" trap in Visual BASIC or a "try..catch" block in Visual C++.

Example

' First supply a valid SAS format name (COMMA12.2) and then
' an invalid SAS format name (ROMAN5) (no trailing period).
Private Sub Form_Load()
    Dim strFmtName As String

    SASFmts.FormatType = FORMAT_TYPE_FORMAT + FORMAT_TYPE_NUMERIC
    On Error GoTo Form_Load_Format_Error
    ' The first name will be valid.
    strFmtName = "COMMA12.2"
    SASFmts.Format = strFmtName
    ' The first name will be invalid (no trailing period).
    strFmtName = "ROMAN5"
    SASFmts.Format = strFmtName
    On Error GoTo 0
    Exit Sub

Form_Load_Format_Error:
    MsgBox "Error in format name """ + strFmtName + """ - the message was:" + Chr(13) + Chr(10) + Chr(13) + Chr(10) + "    " + Err.Description
    On Error Resume Next
End Sub

See Also

  • FormatType

FormatType Property
Specifies which format or informat categories are to be displayed.

Syntax

SASFmtsObj.FormatType = value

Parameters

value
A long value specifying the categories of formats or informats, as described in the Settings section.

Settings

Valid settings for value follow. The first group of values (0, 16384) describes the type of format; the second group (1, 2, 4, 8, 16, 32, 8192) describes the categories to be displayed. When adding numbers to create a final value for value, use only one number from each group.

0
FORMAT_TYPE_FORMAT - Display formats.

16384 (&H4000&)
FORMAT_TYPE_INFORMAT - Display informats.

1
FORMAT_TYPE_CHARACTER - Display the character category.

2
FORMAT_TYPE_NUMERIC - Display the numeric category.

4
FORMAT_TYPE_DATE - Display the date category.

8
FORMAT_TYPE_TIME - Display the time category.

16 (&H0010)
FORMAT_TYPE_DATETIME - Display the datetime category.

32 (&H0020)
FORMAT_TYPE_CURRENCY - Display the currency category.

8192 (&H2000)
FORMAT_TYPE_USERDEF - Display the user-defined category.

Remarks

The enumerated types FORMAT_TYPE_FORMAT, FORMAT_TYPE_INFORMAT, FORMAT_TYPE_CHARACTER, FORMAT_TYPE_NUMERIC, FORMAT_TYPE_DATE, FORMAT_TYPE_TIME, FORMAT_TYPE_DATETIME, FORMAT_TYPE_CURRENCY and FORMAT_TYPE_USERDEF are defined within the control's type library. They are members of the FORMAT_TYPE enumeration.

Example

SASFmts.FormatType = FORMAT_TYPE_FORMAT + FORMAT_TYPE_NUMERIC + FORMAT_TYPE_CURRENCY

IgnoreInvalidValues Property
Disables and enables the validation of values entered into the edit field subcontrols.

Syntax

SASFmtsObj.IgnoreInvalidValues = value

Parameters

value
A Boolean value specifying whether the values entered within the edit field subcontrols should be validated (FALSE - default) or ignored (TRUE).

Remarks

This property can be used in a handler for a cancel or close operation where the selections and values entered into the SASFmts control are going to be discarded.

Example

Private Sub Form_Load()
    SASFmts.FormatType = FORMAT_TYPE_FORMAT + FORMAT_TYPE_NUMERIC
End Sub

Private Sub btnOK_Click()
    If SASFmts.AllEnteredValuesAreValid() = False Then
        MsgBox "Invalid values exist within the SASFmts control edit fields."
        SASFmts.SetFocus
        Exit Sub
    End If

    Unload Me
End Sub

Private Sub btnCancel_Click()
    SASFmts.IgnoreInvalidValues = True
    Unload Me
End Sub

Private Sub Form_QueryUnload(Cancel As Integer, UnloadMode As Integer)
    If UnloadMode = vbFormControlMenu Or UnloadMode = vbFormOwner Then
        SASFmts.IgnoreInvalidValues = True
    End If
End Sub

See Also

  • AllEnteredValuesAreValid

SAS Format/Informat Selector Control Methods

AllEnteredValuesAreValid Method
Determines whether all values entered in the edit field subcontrols are valid.

Syntax

SASFmtsObj.AllEnteredValuesAreValid ( )

Returns

TRUE if all of the edit field values are valid, FALSE if one or more edit fields contain invalid values.

Remarks

This method should be called from the handler of the event that determines whether the form or dialog that contains the SASFmts control should close or not. In the case of a Visual BASIC form, it would probably be called from the OK, Done and/or Apply button Click event handler, or the Form's QueryClose event handler. In a Visual C++ dialog, it would be called in the ON_BN_CLICKED notification handler for an OK, Done, or Apply pushbutton or the OnClose message handler. For a property page, it should be called from the OnKillActive handler.

Example

Private Sub Form_Load()
    SASFmts.FormatType = FORMAT_TYPE_FORMAT + FORMAT_TYPE_NUMERIC
End Sub

Private Sub btnOK_Click()
    If SASFmts.AllEnteredValuesAreValid() = False Then
        MsgBox "Invalid values exist within the SASFmts control edit fields."
        SASFmts.SetFocus
        Exit Sub
    End If

    Unload Me
End Sub

Private Sub btnCancel_Click()
    SASFmts.IgnoreInvalidValues = True
    Unload Me
End Sub

Private Sub Form_QueryUnload(Cancel As Integer, UnloadMode As Integer)
    If UnloadMode = vbFormControlMenu Or UnloadMode = vbFormOwner Then
        SASFmts.IgnoreInvalidValues = True
    End If
End Sub

See Also

  • IgnoreInvalidValues

ChangeNoneToDefault Method
Changes the default text displayed within the categories list that indicates no selection from None to Default.

Syntax

SASFmtsObj.ChangeNoneToDefault (value)

Parameters

value
Required. A Boolean value specifying whether the entry in the categories list should be changed to Default (TRUE) or remain as None (FALSE). The default is FALSE.

Example

SASFmts.ChangeNoneToDefault TRUE

See Also

  • MakeNothingSelected

MakeNothingSelected Method
Removes the selections from both the Categories and Formats list controls.

Syntax

SASFmtsObj.MakeNothingSelected ( )

Example

SASFmts.MakeNothingSelected

SetDataAccessorUnknown Method
Returns information about the custom color at a particular index position within the custom color palette.

Syntax

SASFmtsObj.SetDataAccessorUnknown (segdata)

Parameters

segdata
Required. A SEGData pointer referencing the current SAS server.

Returns

TRUE if successful, FALSE if an error condition occurred.

Remarks

If this method is not called, then a very limited set of basic SAS formats is provided from an internal table. Also, in this scenario, although user-defined format names may be entered, no validation of the existence of the format can be performed.

Example

Public Application As SEGApplication   ' Initialized by SEGAddIn_Connect

Private Data As SEGData
.
.
.

Private Sub Form_Load
    Dim bRC As Boolean

    Application.GetActiveData Data

    bRC = SASFmts.SetDataAccessorUnknown(Data)
    If bRC = False Then
        MsgBox "SetDataAccessorUnknown returned an error."
    End If
    .
    .
    .
    .
End Sub

SplitUpFormat Method
A utility method that splits a format name into name, width, and decimal values.

Syntax

SASFmtsObj.SplitUpFormat (fullname, name, width, decimal)

Parameters

fullname
Required. A string value specifying the format name to be split into its component parts.

name
Required. A string variable which returns the name part of the format, including the dollar sign ($) if the name specifies a character format or informat.

width
Required. A long variable in which the width value is returned. The value is -1 if there is no width component within the format specification.

decimal
Required. A long variable in which the decimal value will be returned. The value is -1 if there is no decimal component within the format specification.

Returns

TRUE if the format was successfully split up, FALSE if the string contains an invalid format specification.

Remarks

Using this method has no effect on the SASFmts control itself. It is simply a utility to assist in splitting a format specification into its component parts.

Example

Dim strFmtName As String
Dim lWidth As Long
Dim lDecimal As Long
Dim bRC As Boolean

bRC = SASFmts.SplitUpFormat("$DEPTCODE7.", strFmtName, lWidth, lDecimal)

If bRC = False Then
    MsgBox "The format supplied to SplitUpFormat() contained an error."
Else
    MsgBox "Name = " + strFmtName + Chr(13) + Chr(10) + "Width = " + Str(lWidth) + Chr(13) + Chr(10) + "Decimal = " + Str(lDecimal)
End If

SAS Format/Informat Selector Control Events

FormatChangedV3 Event
Occurs when a new format is selected or properties of the selected format are changed.

Syntax

Private Sub SASFmtsObj.FormatChangedV3 (ByVal format As String, ByVal type As Long)

Parameters

format
A string value which contains the new format specification. An empty string indicates that there is currently no selected format.

type
An integer value which contains the category that the new format belongs to, as described in the Settings section.

Settings

Valid settings for type are:

1
FORMAT_TYPE_CHARACTER - Display the character category.

2
FORMAT_TYPE_NUMERIC - Display the numeric category.

4
FORMAT_TYPE_DATE - Display the date category.

8
FORMAT_TYPE_TIME - Display the time category.

16 (&H0010)
FORMAT_TYPE_DATETIME - Display the datetime category.

32 (&H0020)
FORMAT_TYPE_CURRENCY - Display the currency category.

8192 (&H2000)
FORMAT_TYPE_USERDEF - Display the user-defined category.

FormatEnumeration Event
Occurs both before and after the control enumerates the names of all the available formats on the server.

Syntax

SASFmtsObj.FormatEnumeration (ByVal busy As Boolean)

Parameters

busy
A Boolean value that indicates whether the format enumeration process is about to begin and therefore the hourglass pointer should be displayed by the parent window (TRUE), or whether the format enumeration process has now completed and therefore the normal pointer for the parent window should be restored (FALSE).

Remarks

If the form (window) which contains the SASFmts control is itself the child of another window, then the container may also have to notify the parent window that its mouse pointer should also be changed.

Example

Private Sub SASFmts_FormatEnumeration(ByVal bBusy As Boolean)
    If bBusy Then
        Form.MousePointer = 11    ' Show the hourglass pointer
    Else
        Form.MousePointer = 0     ' Show the default pointer
    End If

    '
    ' May need to tell the form's parent to also change its
    ' mouse pointer.
    '

End Sub

SAS Data Set Selector Control

 The SAS Data Set Selector Control allows the user to specify the name and location in which to store output data.

File Name

SASDSSel.OCX

Current Interface Version

1

Current CoClass Name

SASDatasetSelector

Remarks

This control is primarily used to name output data and to specify where the data is stored.

Properties Overview

DatasetName | Specifies the name of the data file.
LibraryName | Specifies the SAS data library containing the data file.
ServerName | Specifies the server on which the SAS data library resides.

Events Overview

DatasetNameChanged | Occurs when a data set name is changed.
LibraryNameChanged | Occurs when the library name is changed.
ServerNameChanged | Occurs when the name of the server is changed.

SAS Data Set Selector Control Properties

DatasetName Property
Specifies the name of the current data set.

Syntax

SASDSSelObj.DatasetName = value

Parameters

value
A string value specifying the name of the current data set.

Example

SASDSSel.DatasetName = "SaleInfo"

See Also

  • DatasetNameChanged

  • LibraryName

  • ServerName

LibraryName Property
Specifies the name of the library that contains the current data set.

Syntax

SASDSSelObj.LibraryName = value

Parameters

value
A string value specifying the name of the SAS data library that contains the current data set.

Example

Dim strOutName as String

Private Sub SASDSSel_LibraryNameChanged(ByVal pLibraryName As String)
    strOutName = pLibraryName & "." & SASDSSel.DatasetName
End Sub

See Also

  • LibraryNameChanged

  • DatasetName

  • ServerName

ServerName Property
Specifies the name of the server that contains the current data set.

Syntax

SASDSSelObj.ServerName = value

Parameters

value
A string value specifying the name of the server that contains the current data set.

Example

SASDSSel.ServerName = "Jeeves"

See Also

  • ServerNameChanged

  • DatasetName

  • LibraryName

SAS Data Set Selector Control Events

DatasetNameChanged Event
Occurs when the data set name has changed.

Syntax

SASDSSelObj.DatasetNameChanged (ByVal datasetname As String)

Parameters

datasetname
Returns a string that contains the new name for the data set.

Example

Dim strOutName as String

Private Sub SASDSSel_DatasetNameChanged(ByVal pDatasetName As String)
    strOutName = SASDSSel.LibraryName & "." & pDatasetName
End Sub

See Also

  • DatasetName

  • LibraryNameChanged

  • ServerNameChanged

LibraryNameChanged Event
Occurs when the library name has changed.

Syntax

SASDSSelObj.LibraryNameChanged (ByVal libraryname As String)

Example

Dim strOutName as String

Private Sub SASDSSel_LibraryNameChanged(ByVal pLibraryName As String)
    strOutName = pLibraryName & "." & SASDSSel.DatasetName
End Sub

See Also

  • LibraryName

  • DatasetNameChanged

  • ServerNameChanged

ServerNameChanged Event
Occurs when the server name has changed.

Syntax

SASDSSelObj.ServerNameChanged (ByVal servername As String)

Parameters

servername
Returns a string that contains the new server name.

Example

Dim strServerName as String

Private Sub SASDSSel_ServerNameChanged(ByVal pServerName As String)
    strServerName = pServerName
End Sub

See Also

  • DatasetNameChanged

  • LibraryNameChanged

  • ServerName

SAS Enhanced Editor Control

 The SAS Enhanced Editor control is an editor for editing and displaying SAS code with color-coded keywords and collapsible sections of code.

File Name

SASEEdit.OCX

Current Interface Version

1

Current CoClass Name

EditorControl

Remarks

This documentation, while not complete, provides enough information for the SAS Enhanced Editor to be used as a code preview window within Enterprise Guide add-in tasks.

The control automatically reflects any changes made to the editor properties within the Enterprise Guide options dialogs.

Properties Overview

ReadOnly | Specifies whether or not the text displayed within the control is editable.
Text | The text displayed within the control.

SAS Enhanced Editor Control Properties

ReadOnly Property
Specifies whether or not the text displayed within the control is editable.

Syntax

SASEEditObj.ReadOnly = value

Parameters

value
A Boolean value specifying whether editing of the text contained within the control should be enabled (FALSE) or disabled (TRUE). The default is FALSE.

Example

EnhancedEditor.ReadOnly = True

Text Property
The text displayed within the control.

Syntax

SASEEditObj.Text = value

Parameters

value
A string value which contains all the text displayed within the control. CR/LF pairs are used to terminate lines, and tab characters may be used for horizontal spacing.

Example

Dim strCRLF As String

strCRLF = Chr(13) & Chr(10)

EnhancedEditor.Text = "PROC PRINT DATA=SASHELP.Class;" & strCRLF & "RUN;"