Previous PageNext Page

Updating a SAS data set

Values of some variables for some observations may be updated using a data step. If you have a master data set and you need to update some information - for example, you didn't have the subject's date of birth when the subject was first added to the master data set, but you have that information now - use the UPDATE statement.

DATA Master;
   INPUT @1  ID       3.
         @5  GENDER  $1.
         @7  AGE      2.
         @10 HEIGHT   2.
         @13 DOB      MMDDYY6.;
FORMAT DOB MMDDYY10.;
DATALINES;
101 M 26 68 012366
102 M    78 
103 F 45 62 112647
104   22 66 080170
;
Proc Print data=Master;
	Title "Master Data Set";
Data UpdateIt;
	Informat DOB mmddyy6.;
	Input ID Gender=$ Age= Height= DOB=; * NAMED input;
datalines;
102 DOB=031460 Age=32
104 Gender=F
;
Proc Print data=UpdateIt;
	Format DOB date9.;
	Title "Transaction Data Set";
Data Master;
	Update Master UpdateIt;
	By ID;
Proc Print data=Master;
	Title "Updated Master Data Set";

Previous PageTable Of ContentsNext Page