Hi.
Depending on the number of tests/formats, you could automate the format transformation by loading everything into one or two macro lists.
[pre]
proc sql noprint;
select TEST, SIFMT into :L_TESTS separated by ' ' , :L_TESTS_FMT separated by ' ' from TESTSLIST;
quit;
%put L_TESTS=&L_TESTS;
%put L_TESTS_FMT=&L_TESTS_FMT;
[/pre]
This will populate two macro vars (L_TEST and L_TESTS_FMT) each other with a list of elements (one with the test name, and the other with the corresponding format) separated by blanks.
Then you need to make a match when processing data with the corresponding test name to obtain its index position on the list. Then, the second list (the one with the formats) will hold at the same position the adequate format. Just pass it to the putn function, and its a done deal.
Something like this:
[pre]
data OUTDATA;
set INDATA;
* cycle through the list, match the test name and retrieve the element index;
IDX=0;
do until(scan("&L_TESTS",IDX) eq TEST or scan("&L_TESTS",IDX) eq '');
IDX+1;
end;
if scan("(&L_TESTS",IDX) eq '' then IDX=0; * test name not matched, IDX=0;
* apply automatically the correct format;
FINAL=putn(result*factor,scan(symget('L_TESTS_FMT'),IDX,' '));
run;
[/pre]
Completely automatic and not quite complex as it may seem.
Cheers from Portugal.
Daniel Santos @
www.cgd.pt