%macro get_num_char(dst,v1,f1) ; data nc_&dst.; set &dst.; length &v1._num 8.; length &v1._char $20.; &v1._type = vtype(&v1.); if &v1._type='N' then do; &v1._num=&v1.; &v1._char=strip(put(&v1.,&f1.)); end; if &v1._type='C' then do; &v1._char=&v1.; &v1._num=input(&v1.,&f1.); end; run; %mend get_num_char; data test; a1 = '2025-12-05'; a2 = 45996; run; %get_num_char(test, a1, yymmdd10.); %get_num_char(test, a2, yymmdd10.); The first code "%get_num_char(test, a1, yymmdd10.);" log reports an error "The format $YYMMDD was not found or could not be loaded.". Strangely, this error seems to be reported when Macro runs "&v1._char=strip(put(&v1.,&f1.));" when a1 is a character variable rather than a number. I think "if &v1._type='N' then do;" has prevented following code block from running so it shouldn't report an error. Can anyone tell me why this happened?
... View more