function split(by, code)
	if ~def(by)
		error("BY is missing. Correct comand is '!split by='")
	end
	if ~def(code)
		error("CODE is missing. Correct comand is '!split by=Variable/ code='")
	end
	by = ucase(by);
	pok = GetVarPos(by(1));
	if (pok==0)
		error("Variable '"+by+"' doesn't exist.")
	end
	mul_typ = DataIsMultiple(by);
	[a,b] = freq(Data(:,by));
	old_filter = filter_name;
	DataSelect();
	i = GetVarPos("SELBY$");
	if (i==0)
		DataAddVar("SELBY$");
	end
	labvar = GetVarLabel(by);
	if mul_typ<2
	  siza = size(a,1);
	else
	  bin_vars = GetVarName(by);
	  siza = max(size(bin_vars));
	  vals = GetMulVal(by);
	  varss = "[";
	  for hh=1:size(vals,1)
	    varss = varss+num2str("%d",vals(hh));
	    if hh~=size(vals,1)
	      varss = varss+",";
	    end
	  end
	  vals = varss+"]";
	end
	for hh=1:siza
		%select([by,"==",num2str("%d",hh)]);
		if (mul_typ == 0)
		  filt = calcFilter([by,"==",num2str("%d",a(hh))]);
		  lab= GetNumLabel(GetVarName(by),a(hh));
		elseif (mul_typ == 1)
		  filt = calcFilter([by,"rin",num2str("%d",a(hh))]);
		  lab= GetNumLabel(GetVarName(by),a(hh));
		elseif (mul_typ == 2)
		  filt = calcFilter([bin_vars(hh),"rin",vals]);
		  lab= GetVarLabel(bin_vars(hh));
		end
		if old_filter==""
			Data(:,"SELBY$")=filt;
		else
			Data(:,"SELBY$")=Data(:,old_filter) & filt;
		end
		DataSelect("SELBY$");
		heading(2,labvar+" : "+lab)
		eval(code);
		DataSelect();
	end
	DataSelect(old_filter);
end