Thursday, April 10, 2008

The DATASETS Procedure

You can use the DATASETS procedure to modify a variable’s
name
label
format
informat.

PROC DATASETS LIBRARY=libref ;
MODIFY SAS-data-set ;
RENAME old-name-1=new-name-1
<. . . old-name-n=new-name-n>;
LABEL variable-1='label-1' <. . . variable-n='label-n'>;
FORMAT variable-list-1 format-1 <. . . variable-list-n format-n>;
INFORMAT variable-list-1 informat-1 <. . . variable-list-n informat-n>;
RUN;

Use the DATASETS procedure to change the name of the variable Dest to Destination.
Look at the attributes of the variables in the ia.dfwlax data set.

proc contents data=ia.dfwlax;
run;

Rename the variable Dest to Destination.
proc datasets library=ia;
modify dfwlax;
rename Dest=Destination;
run;

-----Alphabetic List of Variables and Attributes-----

# Variable Type Len Pos
--------------------------------------
2 Date Char 8 19
3 Destination Char 3 27
5 Economy Num 8 8
4 FirstClass Num 8 0
1 Flight Char 3 16

No comments:

Post a Comment