Hello, I want to create a new batch of all the variables in my dataset for each value of two variables: (1) production_year and (2) quarter. For instance, if production_year = 1984 and quarter = 00, then I want to create and add a new batch of variables to my dataset with the suffix "_1984_00". Using the code below, I have to first subset my data by production_year and quarter and then merge them back together. I am very new to macros . . . I was able to find a macro online and modify it for static renaming purposes. Since I am working with more than 80 production_year and quarter combinations, I am trying to find a way to do this more dynamically. Any ideas? %macro rename(oldvarlist, suffix);
%let k=1;
%let old = %scan(&oldvarlist, &k);
%do %while("&old" NE "");
rename &old = &old.&suffix;
%let k = %eval(&k + 1);
%let old = %scan(&oldvarlist, &k);
%end;
%mend;
data ohprod.production_1984_00;
set ohprod.combined_production;
WHERE PRODUCTION_YEAR = "1984" and
QUARTER = "00";
run;
data ohprod.production_1984_00_final;
set ohprod.production_1984_00;
%rename (ACRES_NO APPROVED_BY COMMENTS_PRODUCTION DAYS DECIMAL_WORKING_INTEREST DT_FIRST_PRODUCTION
DT_MODIFIED_PRODUCTION DT_RECEIVED ENTERED_BY FLAG_1 MAXIMUM_STORAGE_CAPACITY
OIL_STORAGE OWNER_NAME OWNER_NO_PRODUCTION PARCEL_NO PERMIT PRODUCTION_BRINE PRODUCTION_GAS
PRODUCTION_OIL PRODUCTION_OIL_GAS_TOTAL PRODUCTION_YEAR QUARTER TAXING_DISTRICT UPSIZE_TS_PRODUCTION
WELL_NAME_PRODUCTION WELL_NO_PRODUCTION YEAR_ORDER, _1984_00);
run;
... View more