Search notes:

SAS data step: update

Updating a data set

The update statement creates a new data set by coping values from a master data set and applying changes from a transaction data set.
In the following example, a master data set is created (tq84_master) which contains a typo and a »missing« observation. Both issues are fixed by applying the tq84_transaction data set:
data tq84_master;
  length txt $10.;
  num = 1; txt = 'one'  ; output;
  num = 2; txt = 'two'  ; output;
  num = 3; txt = 'trhee'; output; /* Note the typo      */
  num = 4; txt = 'four' ; output;
  num = 6; txt = 'six'  ; output; /* Note the missing 5 */
run;

data tq84_transaction;
  length txt $10.;
  num = 3; txt = 'three'; output; /* Fix the typo        */
  num = 5; txt = 'five' ; output; /* Add the missing 5   */
run;

data tq84_updated;
  update
    tq84_master
    tq84_transaction;
    by num;
run;

proc print data=tq84_updated noobs; run;
/*
   txt     num
  
  one       1 
  two       2 
  three     3 
  four      4 
  five      5 
  six       6 
*/
Github repository about-SAS, path: /programming/data-step/update/basic.sas

See also

merge
data step

Index

Fatal error: Uncaught PDOException: SQLSTATE[HY000]: General error: 8 attempt to write a readonly database in /home/httpd/vhosts/renenyffenegger.ch/php/web-request-database.php:78 Stack trace: #0 /home/httpd/vhosts/renenyffenegger.ch/php/web-request-database.php(78): PDOStatement->execute(Array) #1 /home/httpd/vhosts/renenyffenegger.ch/php/web-request-database.php(30): insert_webrequest_('/notes/Companie...', 1759408133, '216.73.216.42', 'Mozilla/5.0 App...', NULL) #2 /home/httpd/vhosts/renenyffenegger.ch/httpsdocs/notes/Companies-Products/SAS/programming/data-step/update/index(82): insert_webrequest() #3 {main} thrown in /home/httpd/vhosts/renenyffenegger.ch/php/web-request-database.php on line 78