Published on :
Data Access INTERNAL_CREATION

Netezza Data Connector

This code is also available in: Deutsch Español Français
Awaiting validation
This connector provides an interface between the SAS© Viya environment and Netezza data sources. It allows users to read data from Netezza into CAS tables, write CAS tables to Netezza, and execute distributed processing operations on this data. Integration is done via the CAS library (CASLIB) or CASUTIL procedures, which provide the necessary mechanisms to specify connection options (server, port, database, credentials) and data transfer parameters. It supports various transfer modes to optimize performance and resource management when moving data between Netezza and CAS.
Data Analysis

Type : INTERNAL_CREATION


Examples use generated data (datalines) or SASHELP to simulate operations. Netezza connection parameters are fictitious and must be replaced with real information for execution in a production environment.

1 Code Block
CASLIB / PROC CASUTIL Data
Explanation :
This example initializes a CAS library (CASLIB) named 'myNetezza' that connects to a Netezza database. It then simulates a local table to show how data could be prepared. Finally, it uses the `PROC CASUTIL` procedure with the `LOAD` action to load an existing Netezza table (named 'ma_table_netezza' in the example) into an in-memory CAS table, making it available for SAS Viya analyses. The `PROMOTE` option makes the table visible to all CAS sessions.
Copied!
1/* Établit une connexion basique à Netezza et charge une table */
2 
3/* Crée une CASLIB pour Netezza */
4CASLIB myNetezza LIBREF=netezza DATASOURCE=(DBCONNECTOPTS=(
5 SERVER='mon_serveur_netezza.com'
6 PORT=5480
7 DATABASE='ma_base_netezza'
8 UID='utilisateur'
9 PWD='motdepasse'
10 SCHEMA='mon_schema'
11)) SESSION=CAS;
12 
13/* Simule une petite table SAS en mémoire CAS */
14DATA casuser.local_data;
15 INPUT ID $ Value;
16 DATALINES;
17 A 10
18 B 20
19 C 30
20 ;
21RUN;
22 
23/* Charge une table depuis Netezza dans CAS (remplacez 'ma_table_netezza' par le nom réel) */
24PROC CASUTIL;
25 LOAD CASDATA="ma_table_netezza" INCASLIB="myNetezza" OUTCASLIB="casuser" PROMOTE;
26RUN;
27 
28/* Vérifie que la table est chargée en mémoire CAS */
29PROC CASSESSION;
30 list tables;
31QUIT;
32 
33/* Nettoyage : supprimer la table CAS et la CASLIB */
34/*
35PROC CASUTIL;
36 DROP TABLE casuser.ma_table_netezza;
37RUN;
38CASLIB _ALL_ PURGE;
39*/
2 Code Block
PROC CASUTIL
Explanation :
This example illustrates loading a Netezza table into CAS using advanced import options. It specifies the columns to include ('ProduitID', 'Quantite', 'PrixUnitaire') and applies a `WHERE` clause to filter records where 'Quantite' is greater than 100. This allows loading only a relevant subset of the data, thereby optimizing CAS memory usage and analysis performance.
Copied!
1/* Charge une table Netezza dans CAS avec sélection de colonnes et filtrage */
2 
3/* Assurez-vous que la CASLIB 'myNetezza' de l'exemple 1 est définie ou définissez-la ici */
4CASLIB myNetezza LIBREF=netezza DATASOURCE=(DBCONNECTOPTS=(
5 SERVER='mon_serveur_netezza.com'
6 PORT=5480
7 DATABASE='ma_base_netezza'
8 UID='utilisateur'
9 PWD='motdepasse'
10 SCHEMA='mon_schema'
11)) SESSION=CAS;
12 
13/* Charge une table de Netezza en sélectionnant des colonnes et en appliquant un filtre */
14PROC CASUTIL;
15 LOAD CASDATA="table_ventes_netezza" INCASLIB="myNetezza" OUTCASLIB="casuser" PROMOTE
16 IMPORTOPTIONS=(SET=(SELECT="ProduitID" "Quantite" "PrixUnitaire")
17 WHERE="Quantite > 100");
18RUN;
19 
20/* Affiche les premières lignes de la table chargée */
21PROC CAS;
22 FEDSQL exec_sql_code='SELECT * FROM casuser.table_ventes_netezza LIMIT 5;';
23QUIT;
24 
25/* Nettoyage : supprimer la table CAS */
26/*
27PROC CASUTIL;
28 DROP TABLE casuser.table_ventes_netezza;
29RUN;
30*/
3 Code Block
PROC CASUTIL Data
Explanation :
This example demonstrates how to create a new in-memory CAS table and export it to the Netezza database. The `PROC CASUTIL` procedure with the `SAVE` action is used, specifying the Netezza CASLIB as the destination. The `REPLACE` option indicates that if a table with the same name already exists in Netezza, it will be replaced. This is useful for synchronization or persistence of analysis results.
Copied!
1/* Crée une table CAS et l'écrit dans Netezza */
2 
3/* Assurez-vous que la CASLIB 'myNetezza' est définie */
4CASLIB myNetezza LIBREF=netezza DATASOURCE=(DBCONNECTOPTS=(
5 SERVER='mon_serveur_netezza.com'
6 PORT=5480
7 DATABASE='ma_base_netezza'
8 UID='utilisateur'
9 PWD='motdepasse'
10 SCHEMA='mon_schema'
11)) SESSION=CAS;
12 
13/* Crée une table CAS avec des données d'exemple */
14DATA casuser.nouvelles_donnees_cas;
15 INPUT ClientID $ Statut;
16 DATALINES;
17 C001 Actif
18 C002 Inactif
19 C003 Actif
20 ;
21RUN;
22 
23/* Écrit la table CAS vers Netezza */
24PROC CASUTIL;
25 SAVE CASDATA="nouvelles_donnees_cas" OUTCASLIB="myNetezza" REPLACE;
26RUN;
27 
28/* Affiche un message de confirmation (hypothétique) */
29/* (Dans un vrai environnement, vous vérifieriez dans Netezza directement) */
30%PUT %STR(INFO: La TABLE 'nouvelles_donnees_cas' a été sauvegardée dans Netezza.);
31 
32/* Nettoyage : supprimer la table CAS */
33/*
34PROC CASUTIL;
35 DROP TABLE casuser.nouvelles_donnees_cas;
36RUN;
37*/
4 Code Block
PROC CAS / PROC CASUTIL Data
Explanation :
This example illustrates a complete workflow involving Netezza and CAS. It starts by creating a CASLIB for Netezza, then creates an in-memory SAS table in CAS with simulated transaction data. Next, it uses `PROC CAS` with `FEDSQL` to execute an SQL query that aggregates amounts by category, storing the result in a new CAS table. Finally, this aggregated table is saved to the Netezza database, thereby demonstrating SAS Viya's ability to perform in-memory analyses on Netezza data and persist modified or aggregated results back to the original source.
Copied!
1/* Charge des données de Netezza, effectue une agrégation en CAS, puis sauvegarde les résultats dans Netezza */
2 
3/* Assurez-vous que la CASLIB 'myNetezza' est définie */
4CASLIB myNetezza LIBREF=netezza DATASOURCE=(DBCONNECTOPTS=(
5 SERVER='mon_serveur_netezza.com'
6 PORT=5480
7 DATABASE='ma_base_netezza'
8 UID='utilisateur'
9 PWD='motdepasse'
10 SCHEMA='mon_schema'
11)) SESSION=CAS;
12 
13/* Simule une table de données 'transactions' en CAS */
14DATA casuser.transactions;
15 INPUT Categorie $ Montant;
16 DATALINES;
17 Alimentation 150
18 Vêtements 200
19 Alimentation 50
20 Électronique 1000
21 Vêtements 300
22 ;
23RUN;
24 
25/* Agrège les données en CAS (par exemple, somme des montants par catégorie) */
26PROC CAS;
27 FEDSQL exec_sql_code='CREATE TABLE casuser.somme_par_categorie AS
28 SELECT Categorie, SUM(Montant) AS TotalMontant
29 FROM casuser.transactions
30 GROUP BY Categorie;';
31QUIT;
32 
33/* Sauvegarde la table agrégée dans Netezza */
34PROC CASUTIL;
35 SAVE CASDATA="somme_par_categorie" OUTCASLIB="myNetezza" REPLACE;
36RUN;
37 
38%PUT %STR(INFO: La TABLE agrégée 'somme_par_categorie' a été sauvegardée dans Netezza.);
39 
40/* Nettoyage : supprimer les tables CAS */
41/*
42PROC CASUTIL;
43 DROP TABLE casuser.transactions;
44 DROP TABLE casuser.somme_par_categorie;
45RUN;
46*/
This material is provided "as is" by We Are Cas. There are no warranties, expressed or implied, as to merchantability or fitness for a particular purpose regarding the materials or code contained herein. We Are Cas is not responsible for errors in this material as it now exists or will exist, nor does We Are Cas provide technical support for it.

Related Documentation : Data Access

Sujet / Mot-cléLien vers la ressource
DOC FedSQL en/sampleCode/FEDSQL9D66