Tips:Macro Language Formatted Look-up

From sasCommunity
Jump to: navigation, search
proc format;
    value $sitecode
        "KETCHIKAN"  = 'A_KTN_' 
        "POW"        = 'B_POW_' 
        "PETERSBURG" = 'C_PTG_' 
        "YAKUTAT"    = 'H_YAK_'
        other        = 'UNK   ';
run;
 
%let site = POW; %* Just an example in this code snippet;
%let code = %sysfunc(putc(&site,$sitecode.));
%put &=code;

The use of formats to perform table look-ups is very common in the DATA step.

Did you know that you can also use formats in to perform table look-ups in the macro language?

The key is to use %SYSFUNC with the PUTC and PUTN functions, which are execution time versions of the PUT function.


....read more

....read more

Submitted By Art Carpenter (talk)