Menu

Read-SasData

Andreas Menrath
Synopsis
    Reads data from a SAS dataset or SAS SQL query and returns all datarows.

Syntax
    Read-SasData [-Workspace] <PSObject> [-Source] <String> [[-ApplyFormats] <SwitchParameter>] [<CommonParameters>]

    Read-SasData [-Workspace] <PSObject> [-Source] <String> [[-ApplyFormats] <SwitchParameter>] [[-AsDataTable] <SwitchParameter>] [<CommonParameters>]


Description



Parameters
    -Workspace <PSObject>
        SAS.Workspace object

        Required?                    true
        Position?                    0
        Default value                
        Accept pipeline input?       true (ByValue)
        Accept wildcard characters?  false

    -Source <String>
        Data source. Can be:
        1) direct source: <libref>.<dataset> e.g. sashelp.class
        2) SAS SQL query: select * from <dataset>

        Required?                    true
        Position?                    1
        Default value                
        Accept pipeline input?       false
        Accept wildcard characters?  false

    -ApplyFormats <SwitchParameter>
        Switch if SAS formats from the data source should be applied. If the switch is deactivated the raw data is displayed.

        Required?                    false
        Position?                    2
        Default value                
        Accept pipeline input?       false
        Accept wildcard characters?  false

    -AsDataTable <SwitchParameter>
        Switch to return a single System.Data.DataTable object instead of multiple System.Data.DataRow objects

        Required?                    false
        Position?                    3
        Default value                
        Accept pipeline input?       false
        Accept wildcard characters?  false



Inputs


Outputs


Notes


Examples
    --------------  Example 1  --------------
    PS C:\> $rows  = Read-SasData $ws "select month from sashelp.prdsale" -ApplyFormats

    $rows | Out-GridView

    use a SAS SQL query, apply the data format and show the results
    --------------  Example 2  --------------
    PS C:\> $rows = Read-SasData $ws "sashelp.class"

    $rows | Out-GridView

    use a data source and show the unformatted results
    --------------  Example 3  --------------
    PS C:\> $rows= Read-SasData $ws "select column1, column2 from `"C:\folder\mydata.sas7bdat`"(obs=10) " -ApplyFormats

    $rows| Out-GridView

    use an advanced SAS SQL query, apply the data format and show the results
    --------------  Example 4  --------------
    PS C:\> $table = Read-SasData $ws "sashelp.class" -AsDataTable

    use a data source and return the result as a DataTable object

Related

Wiki: Home

Want the latest updates on software, tech news, and AI?
Get latest updates about software, tech news, and AI from SourceForge directly in your inbox once a month.