Search code examples
sasproc-format

WARNING: Argument 2 to function PUTC referenced by the %SYSFUNC or %QSYSFUNC macro function is out of range


I am trying to use the product of a Proc Format statement as the format in a %sysfunc statement as so:

proc format;
value myvar
1 = "One" 2 = "Two" 3 = "Three" 4 = "Four";
run;

%let i = 1;

%let dvar = %sysfunc(putc(&i, $myvar.));
%put &dvar;

However I keep getting the error in the title of the post:

WARNING: Argument 2 to function PUTC referenced by the %SYSFUNC or %QSYSFUNC macro function is out of range.

Can anyone tell me why this is?

Thanks


Solution

  • This worked for me in the end:

    proc format;
    value myvar
    1 = "One" 2 = "Two" 3 = "Three" 4 = "Four";
    run;
    
    %let i = 1;
    
    %let dvar = %sysfunc(putn(&i, myvar.));
    %put &dvar;
    

    Thanks