Your question isn't perfectly clear, but if you want to do something like
newvar = put(oldvar,MYFMT.)
->
if x=1 then newvar=put(oldvar,MYFMT.);
else newvar=put(oldvar,MYFMT2.);
But without all of the if statements, you can use PUTN
or PUTC
, which allows you to specify the format at runtime.
newvar = putn(oldvar,fmtvar); *optionally can specify w and d as separate arguments also;