/****************************************************************************** * Programme : Eine DATA Step View erstellen * Reference : EINEDAEB1B * Source : https://www.wearecas.eu/en/sampleCode/EINEDAEB1B ******************************************************************************/ /* --- BLOC 1 --- */ data MonJeuDeDonnees; input ID Nom $ Age; datalines; 1 Jean 25 2 Marie 30 3 Pierre 22 ; run; data MaVueBasique / view=MaVueBasique; set MonJeuDeDonnees; AnneeNaissance = 2025 - Age; run; proc print data=MaVueBasique; run; proc contents data=MaVueBasique; run; /* --- BLOC 2 --- */ data Patients; input PatientID Genre $ Poids Taille; datalines; 1 H 70 175 2 F 60 160 3 H 85 180 4 F 55 165 ; run; data VueIMC / view=VueIMC; set Patients; IMC = Poids / (Taille/100)**2; format IMC 5.1; if Genre = 'F' then Statut = 'Femme'; else Statut = 'Homme'; length Statut $ 5; run; proc print data=VueIMC; run; /* --- BLOC 3 --- */ libname mycas cas; data _null_; file _webout; put '{ "casServer": { "server": "cas-shared-default", "port": 80 } }'; run; proc cas; session casauto; table.droptable / caslib='casuser' name='MaTableCAS' quiet=true; data = {{name='ID', type='double', length=8}, {name='Description', type='varchar', length=50}}; table.addtable / caslib='casuser' name='MaTableCAS' promote=true columns=data; data.appendtable / caslib='casuser' target='MaTableCAS' casdata={{ID=1, Description='Premier article'}, {ID=2, Description='Deuxième article plus long'}, {ID=3, Description='Troisième'}}; print 'Table CAS MaTableCAS créée avec VARCHAR.'; quit; data VueCasVARCHAR / view=VueCasVARCHAR; set mycas.MaTableCAS; LongueurDescription = length(Description); run; proc print data=VueCasVARCHAR; run; proc contents data=VueCasVARCHAR; run; /* --- BLOC 4 --- */ libname mycas cas; proc cas; session casauto; table.droptable / caslib='casuser' name='Employes' quiet=true; data Employes; input EmpID Nom $ Departement $ Salaire; datalines; 101 Jean RH 50000 102 Marie IT 60000 103 Pierre RH 55000 104 Sophie IT 62000 ; run; table.addtable / caslib='casuser' name='Employes' promote=true; table.droptable / caslib='casuser' name='Projets' quiet=true; data Projets; input ProjectID EmpID $ NomProjet $; datalines; P1 101 ProjetX P2 102 ProjetY P3 101 ProjetZ ; run; table.addtable / caslib='casuser' name='Projets' promote=true; print 'Tables CAS Employes et Projets créées.'; quit; data VueRHProjets / view=VueRHProjets; merge Employes (in=e) Projets (in=p); by EmpID; if e and p; where Departement = 'RH'; keep EmpID Nom NomProjet Salaire; run; proc print data=VueRHProjets; run;