A little more complicated example:
data _null_;
set work.rename end=LastName;
if _n_ = 1 then do;
Call execute ("Proc datasets library=&OutDataLib nodetails nolist;");
Call execute ("modify &RenamedData;");
Call execute ("rename ") ;
end;
Call execute(catx(' ',name,' = ',newname)) ;
if LastName then do;
Call execute (";") ;
Call execute ("quit;");
end;
run;
The data set work.rename has a list of variable names that needed to be standardized so contains a Name and Newname variable.
This code creates a call to proc datasets to change the names in place with the modify statement. So we need 1) the start of proc datasets with the library and data set names (strored in macro variables) and the start of a Rename block of code, 2) all of the name to newname pairs and 3) the End option comes in to generate the end of the Rename block and the call to Proc Datasets ;
Sometimes the End option can be used to create a cntlin dataset for Proc Format to set the "other" value options for a format as you need a bit more than a simple list of start and label values.
With the Report Writing Interface for the data step the END option could be used to write what ever might appear at the bottom of any generated text.
... View more