/* Get the current command.                         */
   cmd=upcase(word(1));                                     
                                                            
      /* Execute any custom commands.                     */
   if cmd='KEEP' then link keepvals;                        
   else if cmd = 'RETRIEVE' then link retvals;              


/**********************************************************************/


keepvals:                                                   
                                                            
      /* Open a temporary data set containing all         */
      /* variables on the data set being edited with      */
      /* the FSEDIT procedure.                            */
   pubskel=open('work.pubskel','U');                        
   call set(pubskel);                                       
                                                            
      /* Get the second observation (the first is used    */
      /* for sending letters).                            */
   rc=fetchobs(pubskel,2,'NOSET');                          

      /* Push the current value of all variables          */ 
      /* into the observation.                            */ 
   if update(pubskel) then do;                               
                                                             
  

   end;                                                      
                                                             
      /* We no longer want the DSID to be set,            */ 
      /* so close and then reopen the data set.           */ 
   rc=close(pubskel);                                        
   pubskel=open('work.pubskel','U');                         
                                                             
      /* Again fetch the second observation ...           */ 
   rc=fetchobs(pubskel,2);                                   
                                                             
      /* ... for all variables.  VAR is an SCL list       */ 
      /* that contains character elements, each of        */ 
      /* which names a variable to be duplicated          */ 
   i=0;                                                      
   do while(i<varlen);                                       
      i=i + 1;                                               
      name=getitemc(var,i);                                  
                                                             
            /* Put a missing value in that variable,      */ 
            /* based on the variable type.                */ 
         varnum=varnum(pubskel,name);                        
         if vartype(pubskel,varnum)='C' then                 
            call putvarc(pubskel,varnum,' '); 
         else                                                
            call putvarn(pubskel,varnum,.);                  
      end;                                                   
   end;                                                      
                                                             
      /* Push the new values (blanks on top of old        */ 
      /* values) into the data set.                       */ 
   if update(pubskel) then do;                               
                                                             


   end;                                                      
   rc=close(pubskel);                                        
   return;                                                   
                                                             
retvals:                                                     
                                                             
      /* The TWNUM does not change, even though           */ 
      /* it was either kept or blanked out when the       */ 
      /* KEEP command was issued.                         */ 
   curtw=twnum;                                              
                                                             
      /* Create the DSID for the temporary data set       */ 
      /* and pass it to the SET routine.                  */ 
   pubskel=open('work.pubskel');                             
   call set(pubskel);                                        

      /* Read in all values from the second observation   */ 
      /* (the observation KEEP placed values into).       */ 
   rc=fetchobs(pubskel,2);
   rc=close(pubskel);                                       
                                                            
      /* Be sure to keep the old TWNUM for                */
      /* this observation.                                */
   twnum=curtw;                                             
return;                                                     


/**********************************************************************/