Quelques opérations SAS avec la macro %Windows
par
, 17/07/2015 à 17h16 (782 Affichages)
Bonjour,
Je partage avec vous ce code:
Cordialement
Code : Sélectionner tout - Visualiser dans une fenêtre à part
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80 libname sasref 'C:/sas'; options sasmstore=sasref mstored; %macro operation() /store; %global mv_ope; %window w_saisie color=cyan COLUMNS=40 rows=12 icolumn=30 irow=15 #2 @5 "Opération souhaitée :" @30 mv_ope 100 required=yes; %display w_saisie; run; %mend; %macro saisi_import() /store; %global mv_DATAFILE mv_out mv_sheet; %window w_saisie color=cyan COLUMNS=100 rows=12 icolumn=30 irow=15 #2 @1 "path :" @10 mv_DATAFILE 100 required=yes #5 @1 "table :" @10 mv_out 100 required=yes #7 @1 "Feuile :" @10 mv_sheet 100 required=yes; %display w_saisie; run; %mend; %macro saisi_export() /store; %global mv_data mv_file mv_sheet; %window w_saisie color=cyan COLUMNS=100 rows=12 icolumn=30 irow=15 #2 @1 "table:" @10 mv_data 100 required=yes #5 @1 "chemin :" @10 mv_file 100 required=yes #7 @1 "Feuile :" @10 mv_sheet 100 required=yes; %display w_saisie; run; %mend; %macro saisi_tri() /store; %global mv_data mv_out mv_by; %window w_saisie color=cyan COLUMNS=100 rows=12 icolumn=30 irow=15 #2 @1 "table_ent :" @15 mv_data 100 required=yes #5 @1 "table_sor:" @15 mv_out 100 required=yes #7 @1 "by :" @10 mv_by 100 required=yes; %display w_saisie; run; %mend; %macro Choix() /store; %if &mv_ope=import %then %do; %saisi_import; PROC IMPORT OUT=&mv_out DATAFILE="&mv_path" DBMS=EXCEL REPLACE; SHEET="&mv_sheet"; RUN; %end; %if &mv_ope=export %then %do; %saisi_export; proc export data =&mv_data OUTFILE= "&mv_file" DBMS=EXCEL REPLACE; SHEET="&mv_sheet"; run; %end; %if &mv_ope=tri %then %do; %saisi_tri; PROC sort data=&mv_data out=&mv_out ; by &mv_by ;RUN; %end; %mend; libname sasref 'C:/sas'; OPTIONS MSTORED SASMSTORE = sasref ; %operation; %choix;