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
|
data Classe ;
set sashelp.class;
run;
/*table de correspondance */
data corresp ;
input anc_noms $ nv_noms $ anc_format $ ;
cards;
NAME NAMEN $NAME_F.
AGE AGEN AGE_F.
SEX SEXN $SEX_F.
WEIGHT WEIGHTN WEIGHT_F.
HEIGHT HEIGHTN HEIGHT_F.
;run;
/* renommer les variables */
DATA _null;
SET corresp end=LAST;
IF _n_=1 then call execute ('proc datasets lib=WORK ; modify Classe ; rename') ;
call execute ( compress (anc_noms) !! '=' !! compress (nv_noms) );
IF last then call execute ('; quit ;') ;
run ;
/* créer des nouveaux formats */
data nv_format ;
set corresp ;
if findc(strip(anc_format), '$') then nv_format=cats('$', nv_noms, '_F.') ;
else nv_format=cats(nv_noms, '_F.') ;
run;
proc format;
value $NAMEN_F ;
value AGEN_F ;
value $SEXN_F 'M'='1' 'F'='2' ;
value WEIGHTN_F ;
value HEIGHTN_F ;
run ;
/* renommer les formats */
DATA _null;
SET nv_format end=LAST;
IF _n_=1 then call execute ('proc datasets lib=WORK ; modify Classe ; format') ;
call execute ( strip(nv_noms) !! ' ' !! strip(nv_format) );
IF last then call execute ('; quit ;') ;
run ;
/* Vérification */
proc contents data=Classe ; run ; |
Partager