Bonjour à tous,
Je travaille sur une base oracle que j'essaye d'exporter vers SAS et je cherche à automatiser par une macro l'attribution des formats et labels
des tables dans un fichier SAS. Pour cela j'ai procédé de la manière suivante:
Tout d'abord, j'ai créé une table générale dans la work dans laquelle sont regroupées toutes mes tables.
Puis une tentative de création de macro pour classer mes tables dans un fichier sous forme de data SAS avec leurs attributs, format et labels.
Je sèche sur la macro et toute aide ou critique me serait utile.
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 /* CONNECTION A LA BASE DE L'ETUDE */ libname xx oracle user=xzz password=xxxxxx path="123456"; /* PROCEDURE DE STRUCTURATION DES TABLES SAS RELATIVES A L'ETUDE */ data tables; set dm.Vsas_Tab_Cols_Order ( keep = id_etu table_name column_name data_type data_length label id_the ); where ((id_etu = 2) and ( column_name ne ' ' ) and ((substr (column_name,1,3)) ne "NUM")); attrib column_name label="Variable"; attrib label label="Label"; attrib data_type label="Type"; attrib data_length label="Length"; attrib id_the label="Thesaurus"; attrib table_name label="Table"; run; proc sort data=tables; by table_name column_name; run; data tables2; set tables (keep = table_name column_name label data_type id_the); if id_the ne ' ' then data_type=ide_the; if id_the eq ' ' then data_type=data_type; run; /* MACRO DE CREATION D'ETAPE DATA */ %macro attrib (table); file "D:\DATA xxxxxxxxx\attrib.sas"; set tables; if first.Table then do; if _N_= 1 then put "data &table librairy = librairy"; put / @1 "attrib " variable " " @2 label "='" label "'"; else put / @15 "format= " lenght; end; else if last.Table then put @15 label "='" label "'"; else put / @15 "format= " lenght; end; run; %mend; /* TEST DE LA MACRO */ %attrib (DEMO);
Merci d'avance.
Partager