I have created a job that will compare each variable between two different files (of the same format).
My problem right now is that I need to identify which file the data came from so that others looking at the reports can make sense of it. For instance,
File has the following fields:
I was thinking a simple way to distinguish where the value came from would be to have them called:
INTN_NEW or INTN_OLD
FIRST_NEW or INTN_OLD
LAST_NEW or LAST_OLD
BIRTH_DT_NEW or BIRTH_DT_OLD.
The variable names will change, depending on the files being read in so I can not hard code the variables and their new names. I was thinking a macro might work but then realized that it isn't really a repetitive action since I would be renaming all of the variables for every row at once. I have no idea where to start.
I tried searching these forums for past posts that might help (searched for RENAME, RENAMING, APPEND, ALTER VAR, and none of them had posts which really helped point me in a solid direction).
I guess that you could use some macro programing by using information from DICTIONARY.COLUMNS so you could make your code dynamic. Have a look at proc sql select :into clause, and then use the result with rename data set option.
Yes, DICTIONARY.COLUMNS or PROC CONTENTS with output to a dataset.
Next, you just need to load some macro variables with the input of the DICTIONARY.COLUMS/output from PROC CONTENTS and sufix them with _NEW / _OLD.
proc contents data = WORK.INFILE out = WORK._CONTENTS noprint;
* cats is just use for text trimming;
set WORK._CONTENTS end = _EOF; /* _EOF = 1 when end of file */
/* create VARX_NEW and VARX_OLD macro vars */
/* _N_ is the current observation number, NAME is the variable name */
/* if end of file store VAR_COUNT as total number of variables */
if _EOF then call symput('VAR_COUNT',cats(put(_N_,best.)));