I have a column with name total transaction. I want to add a date 4 days back from now in its name .
For example if today is 20161220 so I want my variable to be renamed as total_transaction_20161216.
Please suggest me a way out of my problem.
Just create a macro variable that stores the required date format and then use that in a rename statement within proc datasets.
rename
proc datasets
%let datevar = %sysfunc(intnx(day,%sysfunc(today()),-4),yymmddn8.); %put &=datevar.; data have; total_transaction=1; run; proc datasets lib=work nolist nodetails; modify have; rename total_transaction = total_transaction_&datevar.; quit;
Just create a macro variable that stores the required date format and then use that in a
rename
statement withinproc datasets
.