I am stacking together several data snapshots that exist in separate tables. The following code iterates over a large number of datestamped snapshots and extracts key-value pairs. Is there a simple way to attach the value of the macro variable &InVar.
within this DATA STEP?
A simple example might have &channels.
with a value of 20140106 20140120 20140127
and &nchannels.
with a value of 3
.
DATA kv_map;
SET
%DO q=1 %TO &nchannels;
%LET InVar=%SCAN(&channels,&q);
%PUT &InVar;
sourcedata.datasnapshot_&InVar.(keep=var_key var_value)
%END;
;
RUN;
The output would then be:
kv_map
╔══════════╦═════════╦════════════╗
║ var_key ║ var_map ║ provenace ║
╠══════════╬═════════╬════════════╣
║ aaa ║ 123 ║ 20140106 ║
║ bbb ║ 432 ║ 20140106 ║
║ ccc ║ 313 ║ 20140106 ║
║ fff ║ 654 ║ 20140120 ║
║ ggg ║ 125 ║ 20140120 ║
║ iii ║ 843 ║ 20140120 ║
║ jjj ║ 864 ║ 20140127 ║
╚══════════╩═════════╩════════════╝
(Table created using http://goo.gl/JIeqZ)