0

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.

Ak204
  • 63
  • 2
  • 8
  • In general purpose while working in SAS i use intnx(date, today(), -4) for getting a date 4 days back from now, but i do not know how to add it in variable name. – Ak204 Dec 20 '16 at 10:34

1 Answers1

1

Just create a macro variable that stores the required date format and then use that in a rename statement within 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;
Longfish
  • 7,582
  • 13
  • 19