![]() |
VOOZH | about |
The CData Cmdlets for SAS xpt are standard PowerShell cmdlets that make it easy to accomplish data cleansing, normalization, backup, and other integration tasks by enabling real-time access to SAS xpt.
The Cmdlets are not only a PowerShell interface to SAS xpt, but also an SQL interface; this tutorial shows how to use both to retrieve SAS xpt data. We also show examples of the ADO.NET equivalent, which is possible with the CData ADO.NET Provider for SASxpt. To access SAS xpt data from other .NET applications, like LINQPad, use the CData ADO.NET Provider for SASxpt.
Once you have acquired the necessary connection properties, accessing SAS xpt data in PowerShell can be enabled in three steps.
You can connect to local SASXpt file by setting the URI to a folder containing SASXpt files.
You can connect to Amazon S3 source to read SASXpt files. Set the following properties to connect:
You can connect to ADLS Gen2 to read SASXpt files. Set the following properties to connect:
Install the module:
Install-Module SASXptCmdlets
Connect:
$sasxpt = Connect-SASXpt -URI "$URI"
Search for and retrieve data:
$column2 = "100" $sampletable_1 = Select-SASXpt -Connection $sasxpt -Table "SampleTable_1" -Where "Column2 = `'$Column2`'" $sampletable_1
You can also use the Invoke-SASXpt cmdlet to execute SQL commands:
$sampletable_1 = Invoke-SASXpt -Connection $sasxpt -Query 'SELECT * FROM SampleTable_1 WHERE Column2 = @Column2' -Params @{'@Column2'='100'}
Load the provider's assembly:
[Reflection.Assembly]::LoadFile("C:\Program Files\CData\CData ADO.NET Provider for SASxpt\lib\System.Data.CData.SASXpt.dll")
Connect to SAS xpt:
$conn= New-Object System.Data.CData.SASXpt.SASXptConnection("URI=C:/folder;")
$conn.Open()
Instantiate the SASXptDataAdapter, execute an SQL query, and output the results:
$sql="SELECT Id, Column1 from SampleTable_1"
$da= New-Object System.Data.CData.SASXpt.SASXptDataAdapter($sql, $conn)
$dt= New-Object System.Data.DataTable
$da.Fill($dt)
$dt.Rows | foreach {
Write-Host $_.id $_.column1
}
Download a free trial of the SASxpt Data Provider to get started:
Download NowLearn more:
👁 SAS XPORT files IconRapidly create and deploy powerful .NET applications that integrate with SAS xpt (XPORT) files data.