Maybe this is too basic, but here's an arguably simpler method: (1) note up to 4 variable names: first, prior, next, and last variables, (2) split the data set at the item to be changed. (3) restore the full data set by remerging the two halves on a shared unique record ID based on _N_. DATA oneA (KEEP=uniquerec name/*--priorvariable*/ sexB ) oneB (KEEP=uniquerec age--weight ) ; /*1st( to n-1th) nth n+1th--last ... where n=position of var. to be changed */ SET sashelp.class; LENGTH sexB $15.; *sexB: will be longer version of variable sex; sexB=sex; *populate longer sexb with original sex values; uniquerec = _N_; DATA newclass (DROP=uniquerec); MERGE oneA oneB; BY uniquerec; RENAME sexB=sex; RUN; *Viola? ; More changed variables just require more "splits" of the data to contiguous chunks oneC, oneD, etc., followed by their re-merge on uniquerec.
... View more