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!
/* Établit une connexion basique à Netezza et charge une table */
/* Crée une CASLIB pour Netezza */
CASLIB myNetezza LIBREF=netezza DATASOURCE=(DBCONNECTOPTS=(
SERVER='mon_serveur_netezza.com'
PORT=5480
DATABASE='ma_base_netezza'
UID='utilisateur'
PWD='motdepasse'
SCHEMA='mon_schema'
)) SESSION=CAS;
/* Simule une petite table SAS en mémoire CAS */
DATA casuser.local_data;
INPUT ID $ Value;
DATALINES;
A 10
B 20
C 30
;
RUN;
/* Charge une table depuis Netezza dans CAS (remplacez 'ma_table_netezza' par le nom réel) */
PROC CASUTIL;
LOAD CASDATA="ma_table_netezza" INCASLIB="myNetezza" OUTCASLIB="casuser" PROMOTE;
RUN;
/* Vérifie que la table est chargée en mémoire CAS */
PROC CASSEssion;
list tables;
QUIT;
/* Nettoyage : supprimer la table CAS et la CASLIB */
/*
PROC CASUTIL;
DROP TABLE casuser.ma_table_netezza;
RUN;
CASLIB _ALL_ PURGE;
*/
1
/* Établit une connexion basique à Netezza et charge une table */
/* Vérifie que la table est chargée en mémoire CAS */
29
PROC CASSESSION;
30
list tables;
31
QUIT;
32
33
/* Nettoyage : supprimer la table CAS et la CASLIB */
34
/*
35
PROC CASUTIL;
36
DROP TABLE casuser.ma_table_netezza;
37
RUN;
38
CASLIB _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!
/* Charge une table Netezza dans CAS avec sélection de colonnes et filtrage */
/* Assurez-vous que la CASLIB 'myNetezza' de l'exemple 1 est définie ou définissez-la ici */
CASLIB myNetezza LIBREF=netezza DATASOURCE=(DBCONNECTOPTS=(
SERVER='mon_serveur_netezza.com'
PORT=5480
DATABASE='ma_base_netezza'
UID='utilisateur'
PWD='motdepasse'
SCHEMA='mon_schema'
)) SESSION=CAS;
/* Charge une table de Netezza en sélectionnant des colonnes et en appliquant un filtre */
PROC CASUTIL;
LOAD CASDATA="table_ventes_netezza" INCASLIB="myNetezza" OUTCASLIB="casuser" PROMOTE
IMPORTOPTIONS=(SET=(SELECT="ProduitID" "Quantite" "PrixUnitaire")
WHERE="Quantite > 100");
RUN;
/* Affiche les premières lignes de la table chargée */
PROC CAS;
FEDSQL exec_sql_code='SELECT * FROM casuser.table_ventes_netezza LIMIT 5;';
QUIT;
/* Nettoyage : supprimer la table CAS */
/*
PROC CASUTIL;
DROP TABLE casuser.table_ventes_netezza;
RUN;
*/
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 */
/* Affiche les premières lignes de la table chargée */
21
PROC CAS;
22
FEDSQL exec_sql_code='SELECT * FROM casuser.table_ventes_netezza LIMIT 5;';
23
QUIT;
24
25
/* Nettoyage : supprimer la table CAS */
26
/*
27
PROC CASUTIL;
28
DROP TABLE casuser.table_ventes_netezza;
29
RUN;
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!
/* Crée une table CAS et l'écrit dans Netezza */
/* Assurez-vous que la CASLIB 'myNetezza' est définie */
CASLIB myNetezza LIBREF=netezza DATASOURCE=(DBCONNECTOPTS=(
SERVER='mon_serveur_netezza.com'
PORT=5480
DATABASE='ma_base_netezza'
UID='utilisateur'
PWD='motdepasse'
SCHEMA='mon_schema'
)) SESSION=CAS;
/* Crée une table CAS avec des données d'exemple */
DATA casuser.nouvelles_donnees_cas;
INPUT ClientID $ Statut;
DATALINES;
C001 Actif
C002 Inactif
C003 Actif
;
RUN;
/* Écrit la table CAS vers Netezza */
PROC CASUTIL;
SAVE CASDATA="nouvelles_donnees_cas" OUTCASLIB="myNetezza" REPLACE;
RUN;
/* Affiche un message de confirmation (hypothétique) */
/* (Dans un vrai environnement, vous vérifieriez dans Netezza directement) */
%PUT %STR(INFO: La table 'nouvelles_donnees_cas' a été sauvegardée dans Netezza.);
/* Nettoyage : supprimer la table CAS */
/*
PROC CASUTIL;
DROP TABLE casuser.nouvelles_donnees_cas;
RUN;
*/
1
/* Crée une table CAS et l'écrit dans Netezza */
2
3
/* Assurez-vous que la CASLIB 'myNetezza' est définie */
/* Crée une table CAS avec des données d'exemple */
14
DATA casuser.nouvelles_donnees_cas;
15
INPUT ClientID $ Statut;
16
DATALINES;
17
C001 Actif
18
C002 Inactif
19
C003 Actif
20
;
21
RUN;
22
23
/* Écrit la table CAS vers Netezza */
24
PROC CASUTIL;
25
SAVE CASDATA="nouvelles_donnees_cas" OUTCASLIB="myNetezza" REPLACE;
26
RUN;
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
/*
34
PROC CASUTIL;
35
DROP TABLE casuser.nouvelles_donnees_cas;
36
RUN;
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!
/* Charge des données de Netezza, effectue une agrégation en CAS, puis sauvegarde les résultats dans Netezza */
/* Assurez-vous que la CASLIB 'myNetezza' est définie */
CASLIB myNetezza LIBREF=netezza DATASOURCE=(DBCONNECTOPTS=(
SERVER='mon_serveur_netezza.com'
PORT=5480
DATABASE='ma_base_netezza'
UID='utilisateur'
PWD='motdepasse'
SCHEMA='mon_schema'
)) SESSION=CAS;
/* Simule une table de données 'transactions' en CAS */
DATA casuser.transactions;
INPUT Categorie $ Montant;
DATALINES;
Alimentation 150
Vêtements 200
Alimentation 50
Électronique 1000
Vêtements 300
;
RUN;
/* Agrège les données en CAS (par exemple, somme des montants par catégorie) */
PROC CAS;
FEDSQL exec_sql_code='CREATE TABLE casuser.somme_par_categorie AS
SELECT Categorie, SUM(Montant) AS TotalMontant
FROM casuser.transactions
GROUP BY Categorie;';
QUIT;
/* Sauvegarde la table agrégée dans Netezza */
PROC CASUTIL;
SAVE CASDATA="somme_par_categorie" OUTCASLIB="myNetezza" REPLACE;
RUN;
%PUT %STR(INFO: La table agrégée 'somme_par_categorie' a été sauvegardée dans Netezza.);
/* Nettoyage : supprimer les tables CAS */
/*
PROC CASUTIL;
DROP TABLE casuser.transactions;
DROP TABLE casuser.somme_par_categorie;
RUN;
*/
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 */
/* Simule une table de données 'transactions' en CAS */
14
DATA 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
;
23
RUN;
24
25
/* Agrège les données en CAS (par exemple, somme des montants par catégorie) */
26
PROC 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;';
31
QUIT;
32
33
/* Sauvegarde la table agrégée dans Netezza */
34
PROC CASUTIL;
35
SAVE CASDATA="somme_par_categorie" OUTCASLIB="myNetezza" REPLACE;
36
RUN;
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
/*
42
PROC CASUTIL;
43
DROP TABLE casuser.transactions;
44
DROP TABLE casuser.somme_par_categorie;
45
RUN;
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.
SAS and all other SAS Institute Inc. product or service names are registered trademarks or trademarks of SAS Institute Inc. in the USA and other countries. ® indicates USA registration. WeAreCAS is an independent community site and is not affiliated with SAS Institute Inc.
This site uses technical and analytical cookies to improve your experience.
Read more.