SCOPE: interactively tabulate SEER excel variables

by

 

This takes SEER excel column data interactively, tabulate them, write back in table format.

output=xls2tabulate2xls(xlsfilename)
%cheung.r100@gmail.com, Dr. Rex Cheung, Waycross, GA, USA.
%Summer, 2012 at Okefanokee, GA.

function output=xls2tabulate2xls(xlsfilename)
%This program asks the user for the SEER variable stored in excel, it
%tabultes the eleemtns, then write it back to the excel. This facilates
%creation of excel tables for reporting purposes. 

%read the original risk factor column
%open the excel file, and prompt user to select the variable columns for computations
uiwait(msgbox('select the column of data')); %wait for the user to interact
[a b]=xlsread(xlsfilename,-1); %[number text]=xlsread()
if (isempty(a)||isnan(a(2))) %if a is empty, it implies that the column as text as data
    columnname=b(1); %extract the name of the column
    tempinputcol=b(2:end,1); %same as b(2:end)
    
%---------------------------------------------------------   
%when text is the format of the data, it is stored in b
t=tabulate(b);
tmp1 = [t(:,1)];
tmp2 = [t{:,2}]';
tmp3 = [t{:,3}]';

%save the results into an excel. User could copy and paste to create a
%table
  y={'factor',tmp1{:}};
  xlswrite(xlsfilename, y',1,'H1'); %

  z1 = num2cell(tmp2);
  y1={'count',z1{:}};
  xlswrite(xlsfilename, y1',1,'I1'); %

  z2 = num2cell(tmp3);
  y2={'percent',z2{:}};
  xlswrite(xlsfilename, y2',1,'J1'); %

%--------------------------------------------------------
else %when the riskfactor is already number
%when text is the format of the data, it is stored in b
t=tabulate(b);
tmp1 = [t{:,1}]';
tmp2 = [t{:,2}]';
tmp3 = [t{:,3}]';

%save the results into an excel. User could copy and paste to create a
%table
   z = num2cell(tmp1);
   y={'factor',z{:}};
   xlswrite(xlsfilename, y',1,'H1'); %

  z1 = num2cell(tmp2);
  y1={'count',z1{:}};
  xlswrite(xlsfilename, y1',1,'I1'); %

  z2 = num2cell(tmp3);
  y2={'percent',z2{:}};
  xlswrite(xlsfilename, y2',1,'J1'); %
%---------------------------------------------------------
end

output=1;

Contact us