mon master2 ISIFAR
Vous souhaitez réagir à ce message ? Créez un compte en quelques clics ou connectez-vous pour continuer.
mon master2 ISIFAR

ISIFAR
 
AccueilRechercherDernières imagesS'enregistrerConnexion
Le Deal du moment : -15%
(Adhérents Fnac) LEGO® Star Wars™ ...
Voir le deal
552.49 €

 

 TP4 (suite)

Aller en bas 
AuteurMessage
Admin
Admin



Nombre de messages : 418
Date d'inscription : 27/09/2005

TP4 (suite) Empty
MessageSujet: TP4 (suite)   TP4 (suite) Icon_minitimeVen 4 Nov à 20:11

9. Fusion de tableaux avec MERGE+BY

Code:
DATA enfants;
   INPUT prenom $ :12. age genre $ taille poids cheveux;
   CARDS;
ANDREE 13 F 140 38.2 1
BARBARA 13 F 161 44.3 2
BERNADETTE 14 F 155 46.1 3
GAETANE 12 F 148 38.2 3
JEANNE 15 F 155 50.5 1
MARTINE 11 F 123 22.4 2
ODILE 14 F 160 40.4 1
SOLANGE 12 F 140 34.7 3
VALENTINE 15 F 165 50.5 2
ANTOINE 14 M 172 50.5 2
HENRI 13 M 155 38.1 2
PATRICK 12 M 160 57.3 1
THOMAS 11 M 142 39.3 2
BRUNO 14 M 157 46.1 1
FRANCOIS 12 M 142 37.1 1
JEAN 12 M 148 45.9 3
MATHIAS 16 M 180 66.3 2
PHILIPPE 15 M 167 60 1
XAVIER 15 M 165 50.5 1
;
RUN;

DATA poids;
   SET enfants;
   KEEP prenom poids;
RUN;
PROC SORT data=poids;
   by prenom;
RUN;

DATA taille;
   SET enfants;
   KEEP prenom taille;
RUN;
PROC SORT data=taille;
   by prenom;
RUN;

DATA genre;
   SET enfants;
   KEEP prenom genre;
RUN;
PROC SORT data=genre;
   by prenom;
RUN;


DATA fusion_by;
   MERGE poids taille genre;
   by prenom;
RUN;
PROC PRINT data=fusion_by;
RUN;


Dernière édition par le Jeu 24 Nov à 20:50, édité 1 fois
Revenir en haut Aller en bas
https://mastertwo.jeun.fr
Admin
Admin



Nombre de messages : 418
Date d'inscription : 27/09/2005

TP4 (suite) Empty
MessageSujet: Re: TP4 (suite)   TP4 (suite) Icon_minitimeVen 4 Nov à 20:35

Code:
DATA enfants;
   INPUT prenom $ :12. age genre $ taille poids cheveux;
   CARDS;
ANDREE 13 F 140 38.2 1
BARBARA 13 F 161 44.3 2
BERNADETTE 14 F 155 46.1 3
GAETANE 12 F 148 38.2 3
JEANNE 15 F 155 50.5 1
MARTINE 11 F 123 22.4 2
ODILE 14 F 160 40.4 1
SOLANGE 12 F 140 34.7 3
VALENTINE 15 F 165 50.5 2
ANTOINE 14 M 172 50.5 2
HENRI 13 M 155 38.1 2
PATRICK 12 M 160 57.3 1
THOMAS 11 M 142 39.3 2
BRUNO 14 M 157 46.1 1
FRANCOIS 12 M 142 37.1 1
JEAN 12 M 148 45.9 3
MATHIAS 16 M 180 66.3 2
PHILIPPE 15 M 167 60 1
XAVIER 15 M 165 50.5 1
;
RUN;
PROC PRINT;
RUN;
DATA poids;
   SET enfants;
   KEEP prenom poids;
   WHERE cheveux=1;
RUN;
PROC SORT data=poids;
   by prenom;
RUN;
PROC PRINT;
RUN;
DATA taille;
   SET enfants;
   KEEP prenom taille;
   WHERE cheveux=1;
RUN;
PROC SORT data=taille;
   by prenom;
RUN;
DATA genre;
   SET enfants;
   KEEP prenom genre;
   WHERE cheveux=1;
RUN;
PROC SORT data=genre;
   by prenom;
RUN;
DATA fusion_by;
   MERGE poids taille genre;
   by prenom;
RUN;
PROC PRINT data=fusion_by;
RUN;
Revenir en haut Aller en bas
https://mastertwo.jeun.fr
Admin
Admin



Nombre de messages : 418
Date d'inscription : 27/09/2005

TP4 (suite) Empty
MessageSujet: Re: TP4 (suite)   TP4 (suite) Icon_minitimeVen 4 Nov à 20:57

10. L'instruction IN avec MERGE+BY

Code:
DATA FA;
   INPUT tableau $ t x $ z $;
   CARDS;
A 1 X1 Z1
A 2 X2 Z2
A 3 X3 Z3
A 4 X4 Z4
A 5 X5 Z5
A 6 X6 Z6
;
RUN;
PROC PRINT;
RUN;
DATA FB;
   INPUT tableau $ t y $ z $;
   CARDS;
B 5 Y5 Z5b
B 6 Y6 Z6b
B 7 Y7 Z7
B 8 Y8 Z8
B 9 Y9 Z9
B 10 Y10 Z10
;
RUN;
PROC PRINT;
RUN;
DATA tab;
   MERGE FA(in=A) FB(in=B);
   by t;
   IF A and B;
RUN;
PROC PRINT;
RUN;


Dernière édition par le Jeu 24 Nov à 21:10, édité 1 fois
Revenir en haut Aller en bas
https://mastertwo.jeun.fr
Admin
Admin



Nombre de messages : 418
Date d'inscription : 27/09/2005

TP4 (suite) Empty
MessageSujet: Re: TP4 (suite)   TP4 (suite) Icon_minitimeVen 4 Nov à 21:00

équivalent de MERGE+BY

Code:
DATA FA;
   INPUT tableau $ t x $ z $;
   CARDS;
A 1 X1 Z1
A 2 X2 Z2
A 3 X3 Z3
A 4 X4 Z4
A 5 X5 Z5
A 6 X6 Z6
;
RUN;
PROC PRINT;
RUN;
DATA FB;
   INPUT tableau $ t y $ z $;
   CARDS;
B 5 Y5 Z5b
B 6 Y6 Z6b
B 7 Y7 Z7
B 8 Y8 Z8
B 9 Y9 Z9
B 10 Y10 Z10
;
RUN;
PROC PRINT;
RUN;
DATA tab;
   MERGE FA(in=A) FB(in=B);
   by t;
   IF A or B;
RUN;
PROC PRINT;
RUN;
Revenir en haut Aller en bas
https://mastertwo.jeun.fr
Admin
Admin



Nombre de messages : 418
Date d'inscription : 27/09/2005

TP4 (suite) Empty
MessageSujet: Re: TP4 (suite)   TP4 (suite) Icon_minitimeVen 4 Nov à 21:02

Concaténation avec SET

Code:
DATA FA;
   INPUT tableau $ t x $ z $;
   CARDS;
A 1 X1 Z1
A 2 X2 Z2
A 3 X3 Z3
A 4 X4 Z4
A 5 X5 Z5
A 6 X6 Z6
;
RUN;
PROC PRINT;
RUN;
DATA FB;
   INPUT tableau $ t y $ z $;
   CARDS;
B 5 Y5 Z5b
B 6 Y6 Z6b
B 7 Y7 Z7
B 8 Y8 Z8
B 9 Y9 Z9
B 10 Y10 Z10
;
RUN;
PROC PRINT;
RUN;
DATA tab;
   SET FA FB;
RUN;
PROC PRINT;
RUN;
Revenir en haut Aller en bas
https://mastertwo.jeun.fr
Admin
Admin



Nombre de messages : 418
Date d'inscription : 27/09/2005

TP4 (suite) Empty
MessageSujet: Re: TP4 (suite)   TP4 (suite) Icon_minitimeVen 4 Nov à 21:03

complémentaire de FA par rapport à FB


Code:
DATA FA;
   INPUT tableau $ t x $ z $;
   CARDS;
A 1 X1 Z1
A 2 X2 Z2
A 3 X3 Z3
A 4 X4 Z4
A 5 X5 Z5
A 6 X6 Z6
;
RUN;
PROC PRINT;
RUN;
DATA FB;
   INPUT tableau $ t y $ z $;
   CARDS;
B 5 Y5 Z5b
B 6 Y6 Z6b
B 7 Y7 Z7
B 8 Y8 Z8
B 9 Y9 Z9
B 10 Y10 Z10
;
RUN;
DATA tab;
   MERGE FA(in=A) FB(in=B);
   by t;
   IF A and not(B);
RUN;
PROC PRINT;
RUN;
Revenir en haut Aller en bas
https://mastertwo.jeun.fr
Admin
Admin



Nombre de messages : 418
Date d'inscription : 27/09/2005

TP4 (suite) Empty
MessageSujet: Re: TP4 (suite)   TP4 (suite) Icon_minitimeVen 4 Nov à 21:05

mise à jour de FA par FB

Code:
DATA FA;
   INPUT tableau $ t x $ z $;
   CARDS;
A 1 X1 Z1
A 2 X2 Z2
A 3 X3 Z3
A 4 X4 Z4
A 5 X5 Z5
A 6 X6 Z6
;
RUN;
PROC PRINT;
RUN;
DATA FB;
   INPUT tableau $ t y $ z $;
   CARDS;
B 5 Y5 Z5b
B 6 Y6 Z6b
B 7 Y7 Z7
B 8 Y8 Z8
B 9 Y9 Z9
B 10 Y10 Z10
;
RUN;
DATA tab;
   MERGE FA(in=A) FB(in=B);
   by t;
   IF A;
RUN;
PROC PRINT;
RUN;
Revenir en haut Aller en bas
https://mastertwo.jeun.fr
Admin
Admin



Nombre de messages : 418
Date d'inscription : 27/09/2005

TP4 (suite) Empty
MessageSujet: Re: TP4 (suite)   TP4 (suite) Icon_minitimeJeu 24 Nov à 20:52

MERGE+BY
(pour le fun)



Code:
DATA FA;
   INPUT tableau $ t x $ z $;
   CARDS;
A 1 X1 Z1
A 2 X2 Z2
A 3 X3 Z3
A 4 X4 Z4
A 5 X5 Z5
A 6 X6 Z6
;
RUN;

DATA FB;
   INPUT tableau $ t y $ z $;
   CARDS;
B 5 Y5 Z5b
B 6 Y6 Z6b
B 7 Y7 Z7
B 8 Y8 Z8
B 9 Y9 Z9
B 10 Y10 Z10
;
RUN;

DATA fusion_fa_fb;
   MERGE FA FB;
   by t;
RUN;
PROC PRINT;
RUN;
Revenir en haut Aller en bas
https://mastertwo.jeun.fr
Admin
Admin



Nombre de messages : 418
Date d'inscription : 27/09/2005

TP4 (suite) Empty
MessageSujet: Re: TP4 (suite)   TP4 (suite) Icon_minitimeJeu 24 Nov à 21:36

TRAVAUX COMPLEMENTAIRES

Code:
title1 'meteo';
DATA meteo;
   INPUT station $ temp1-temp3;
   temp=temp1; OUTPUT;
   temp=temp2; OUTPUT;
   temp=temp3; OUTPUT;
   CARDS;
sta1 2 3 1
sta2 4 5 3
;
RUN;
PROC PRINT;
RUN;

et maintenant le bon affichage

Code:
title1 'meteo';
DATA meteo;
   INPUT station $ temp1-temp3;
   temp=temp1; OUTPUT;
   temp=temp2; OUTPUT;
   temp=temp3; OUTPUT;
   KEEP station temp;
   CARDS;
sta1 2 3 1
sta2 4 5 3
;
RUN;
PROC PRINT;
RUN;
Revenir en haut Aller en bas
https://mastertwo.jeun.fr
Admin
Admin



Nombre de messages : 418
Date d'inscription : 27/09/2005

TP4 (suite) Empty
MessageSujet: Re: TP4 (suite)   TP4 (suite) Icon_minitimeJeu 24 Nov à 21:45

Opérations, fonctions, boucles
Revenir en haut Aller en bas
https://mastertwo.jeun.fr
Admin
Admin



Nombre de messages : 418
Date d'inscription : 27/09/2005

TP4 (suite) Empty
MessageSujet: Re: TP4 (suite)   TP4 (suite) Icon_minitimeJeu 24 Nov à 21:45

11. Opérations élémentaires

Code:
title1 'operations élémentaires';
DATA nombres;
  INPUT x y @@;
  CARDS;
5 5 2 -3 -4 7.12 8 1.6 2 0
;
RUN;
DATA calculs;
  set nombres;
  a=x+y; b=x-y; c=x**y; d=min(x,y); e=max(x,y); f=x*y; g=x/y;
RUN;
PROC PRINT label;
label a='x+y' b='x-y' c='x**y' d='min(x,y)' e='max(x,y)' f='x*y' g='x/y';
RUN;

Arrow METTRE LES LABELS !!!!


Dernière édition par le Ven 6 Jan à 3:20, édité 5 fois
Revenir en haut Aller en bas
https://mastertwo.jeun.fr
Admin
Admin



Nombre de messages : 418
Date d'inscription : 27/09/2005

TP4 (suite) Empty
MessageSujet: Re: TP4 (suite)   TP4 (suite) Icon_minitimeJeu 24 Nov à 21:51

12. Fonctions courantes

Code:
title1 'fonctions courantes';
DATA nombres;
   INPUT x y @@;
   CARDS;
5 5 2 -3 -4 7.12 8 1.6 2 0
;
RUN;
DATA fcts;
   set nombres;
   a=abs(x); b=exp(x); c=int(y); d=log(y); e=log10(y); f=sign(y); g=sqrt(x);
RUN;
PROC PRINT label;
label a='abs(x)' b='exp(x)' c='int(y)' d='log(y)' e='log10(y)' f='sign(y)' g='sqrt(x)';
RUN;
Revenir en haut Aller en bas
https://mastertwo.jeun.fr
Contenu sponsorisé





TP4 (suite) Empty
MessageSujet: Re: TP4 (suite)   TP4 (suite) Icon_minitime

Revenir en haut Aller en bas
 
TP4 (suite)
Revenir en haut 
Page 1 sur 1
 Sujets similaires
-
» TP5 (suite)

Permission de ce forum:Vous ne pouvez pas répondre aux sujets dans ce forum
mon master2 ISIFAR :: 1er semestre :: SAS-
Sauter vers:  
Ne ratez plus aucun deal !
Abonnez-vous pour recevoir par notification une sélection des meilleurs deals chaque jour.
IgnorerAutoriser