If you are updating a data set, you probably do not want duplicate values of BY variables
in the master data set. For example, if you update by Name, each observation in the
master data set should have a unique value of Name. If you update by Name and Age,
two or more observations can have the same value for either Name or Age but should
not have the same values for both. SAS warns you if it finds duplicates but proceeds
with the update. It applies all transactions only to the first observation in the BY group in
the master data set.
Updating a Data Set
In this example, the circulation department of a magazine maintains a mailing list that
contains tens of thousands of names. Each issue of the magazine contains a form for
readers to fill out when they change their names or addresses. To simplify the
maintenance job, the form requests that readers send only new information. New
subscribers can start a subscription by completing the entire form. When a form is
received, a data entry operator enters the information about the form into a raw data file.
The mailing list is updated once per month from the raw data file.
The mailing list includes these variables for each subscriber:
specifies a unique number that is assigned to the subscriber at the time the
subscription begins. A subscriber's SubscriberId never changes.
specifies the subscriber's name. The last name appears first, followed by a comma
and the first name.
specifies the subscriber's street address.
specifies the subscriber's city.
specifies the subscriber's state or province. This variable is missing for addresses
outside the United States and Canada.
specifies the subscriber's postal code (ZIP code for addresses in the United States).
specifies the subscriber's country.
The following program creates and displays the first part of this data set. The raw data
are already sorted by SubscriberId.
input SubscriberId 1-8 Name $ 9-27 StreetAddress $ 28-47 City $ 48-62
StateProv $ 63-64 PostalCode $ 67-73 Country $ ;
1001 Ericson, Jane 111 Clancey Court Chapel Hill NC 27514 USA
1002 Dix, Martin 4 Shepherd St. Vancouver BC V6C 3E8 Canada
1003 Gabrielli, Theresa Via Pisanelli, 25 Roma 00196 Italy
1004 Clayton, Aria 14 Bridge St. San Francisco CA 94124 USA
1005 Archuleta, Ruby Box 108 Milagro NM 87429 USA
1006 Misiewicz, Jeremy 43-C Lakeview Apts. Madison WI 53704 USA
Updating a Data Set 319