사업자번호구분 코드

Reg_classifier<-function(original_tbl, colname="사업자번호") {
  Reg<-eval(parse(text=paste0("original_tbl$",colname)))
  Reg2<-rep(0,length(Reg))

  tmp<-as.integer(substr(Reg,4,5))
  tmp[which(nchar(Reg)!= 10)]<-00
  tmp[which(is.na(Reg))]<-00

  Reg2[which(tmp>=01 & tmp<=79)]<-"개인과세사업자"
  Reg2[which(tmp>=90 & tmp<=99)]<-"개인면세사업자"
  Reg2[which(tmp==89)]<-"개인사업자_종교단체"
  Reg2[which(tmp==80)]<-"개인사업자_APT다단계"
  Reg2[which(tmp %in% c(81,86,87,88))]<-"법인본점"
  Reg2[which(tmp==82)]<-"법인비영리"
  Reg2[which(tmp==83)]<-"국가지자체"
  Reg2[which(tmp==84)]<-"법인외국"
  Reg2[which(tmp==85)]<-"법인지점"
  Reg2[which(nchar(Reg)!= 10)]<-"ERR"
  Reg2[which(is.na(Reg))]<-"ERR"

  Reg2
}

case
    when length([사업자번호]) <> 10 then 'ERR'
	when [사업자번호] is null then 'ERR'
	when substr([사업자번호],4,2) = '00' then 'ERR'
    when substr([사업자번호],4,2) <= '79' then '개인과세사업자'
	when substr([사업자번호],4,2) >= '90' then '개인면세사업자'
	when substr([사업자번호],4,2) in ('81','86','87','88') then '법인본점'
	when substr([사업자번호],4,2) in ('82') then '법인비영리'
	when substr([사업자번호],4,2) in ('83') then '국가지자체'
	when substr([사업자번호],4,2) in ('84') then '법인외국'
	when substr([사업자번호],4,2) in ('85') then '법인지점'
	when substr([사업자번호],4,2) in ('89') then '개인사업자_종교단체'
	when substr([사업자번호],4,2) in ('80') then '개인사업자_APT다단계'
	else 'ERR'
end

Enter your comment:
X M R W M