Saturday, March 10, 2012

INFORMAT IN SAS

To read a nonstandard data, we must use an informat
The general form of an informat is

<$>INFORMAT-NAME<w>.<d>

The commonly used Informats are

MMDDYYw.- Reads date in the form 12/19/2011
DATEw.        - Reads date in the form 19DEC2011
COMMAw.   - It reads numeric data($5,55) and strips out selected nonnumeric characters, such as dollar sign                                             and commas.


Sunday, March 4, 2012

Merging in SAS

For merging two data sets, we must sort the two data sets by a common variable.
let us consider the two data sets as data1, data2 and the common variable as id.Then after the processing in the data step , we can sort the two sets of data in the procedure step as follows.

proc sort data= mylib.data1;
by id;
run;

proc sort data= mylib.data2;
by id;
run;

After sorting the two data sets we can check whether they are sorted or not by the following procedure step

proc contents data=mylib.data1
run;

proc contents data=mylib.data1
run;

After sorting , we can merge the two data sets as follows

data mylib mdata;
merge mylib.data1 mylib.data2;
by id;
run;

proc print data =mylib.mdata;
run;