Hi, how about ...
data test2; set test;
* input only digits ... course number is numeric; coursenum = input(compress(char,,'KD'),20.);
* flag any character than is not a number or a space; flg1 = ifc(findc(char,,'KDS'), 'fail', 'pass');
* flag any alpha character; flg2 = ifc(anyalpha(char), 'fail', 'pass');
run;
The result appears to fit your rule ... "if there is any character in coloumn then i should show a flag as fail else pass". The accepted correct solution gives a different result. Also, use of ...
if compress(char, ' ', 'A') then flg = "fail";
in that solution will give you a note in the LOG about character-to-numeric conversion.
Obs char coursenum flg1 flg2
1 121egghhh 121 fail fail 2 hfghhhdjdj . fail fail 3 5656566 5656566 pass pass 4 tt4556hyj 4556 fail fail
... View more