BEGIN { FS=OFS="\t" } NR==1 { print "sample_id","group","value","category"; next } { category=($4=="invalid" ? "rejected" : ($3=="NA" ? "missing" : "used")) print $1,$2,$3,category }