%IOSHARES   Estimate shares of compensation and intermediates for
%
%             Sweat Equity in US Private Business
%             by Anmol Bhandari and Ellen McGrattan
%
%           Notes: Run this code on a machine with excel.

%           Ellen McGrattan, 5-24-20


%=======================================================================
%
% NIPA Benchmark IO summary use table (2007, Mil$)
%
%=======================================================================
usetab       = xlsread('../RawData/BEA/IO/SummaryUse07');
ii           = usetab(74,1:71)';
wg           = usetab(75,1:71)';
shr0         = sum(wg)/(sum(wg)+sum(ii))*100;
sumii        = sum(ii);
indii        = [sum(ii(1:2));   % Agriculture
                sum(ii(3:5));   % Mining
                ii(6);          % Utilities
                ii(7);          % Construction
                sum(ii(8:26));  % Manufacturing
                ii(27);         % Wholesale trade
                sum(ii(28:31)); % Retail trade
                sum(ii(32:39)); % Transportation/warehousing
                sum(ii(40:43)); % Information
                sum(ii(44:47)); % Finance/insurance 
                ii(50);         % Rental/leasing (excl HS,ORE)
                sum(ii(51:53)); % Professional 
                ii(54);         % Management
                sum(ii(55:56)); % Administrative
                ii(57);         % Education
                sum(ii(58:61)); % Health
                sum(ii(62:63)); % Arts
                sum(ii(64:65)); % Accommodation
                ii(66)];        % Other

sumwg        = sum(wg);
indwg        = [sum(wg(1:2));   % Agriculture
                sum(wg(3:5));   % Mining
                wg(6);          % Utilities
                wg(7);          % Construction
                sum(wg(8:26));  % Manufacturing
                wg(27);         % Wholesale trade
                sum(wg(28:31)); % Retail trade
                sum(wg(32:39)); % Transportation/warehousing
                sum(wg(40:43)); % Information
                sum(wg(44:47)); % Finance/insurance 
                wg(50);         % Rental/leasing (excl HS,ORE)
                sum(wg(51:53)); % Professional 
                wg(54);         % Management
                sum(wg(55:56)); % Administrative
                wg(57);         % Education
                sum(wg(58:61)); % Health
                sum(wg(62:63)); % Arts
                sum(wg(64:65)); % Accommodation
                wg(66)];        % Other

notin        = [48,49,67:71];
wgshr        = indwg./(indwg+indii)*100;
nishr        = sum(wg(notin))/(sum(wg(notin))+sum(ii(notin)))*100;

%=======================================================================
%
% Pratt's Stats counts and sales by NAICs 
%
%=======================================================================
naicscnt     = xlsread('../RawData/BEA/IO/Pratts_wgts','rawcounts');
naicsale     = xlsread('../RawData/BEA/IO/Pratts_wgts','totalsales');

wgt1         = naicscnt(1:19,7)-sum(naicscnt(1:19,2:3)')';
wgt2         = naicsale(1:19,7)-sum(naicsale(1:19,2:3)')';
shr1         = sum(wgshr.*wgt1)/sum(wgt1);
shr2         = sum(wgshr.*wgt2)/sum(wgt2);

disp('------------------------------------')
disp('  Compensation Share of Input Costs ')
disp('     % comp/(comp+int. inputs)      ')
disp('------------------------------------')
disp(sprintf(' Agriculture            %7.1f',wgshr(1)))
disp(sprintf(' Mining                 %7.1f',wgshr(2)))
disp(sprintf(' Utilities              %7.1f',wgshr(3)))
disp(sprintf(' Construction           %7.1f',wgshr(4)))
disp(sprintf(' Manufacturing          %7.1f',wgshr(5)))
disp(sprintf(' Wholesale trade        %7.1f',wgshr(6)))
disp(sprintf(' Retail trade           %7.1f',wgshr(7)))
disp(sprintf(' Transportation         %7.1f',wgshr(8)))
disp(sprintf(' Information            %7.1f',wgshr(9)))
disp(sprintf(' Finance/insurance      %7.1f',wgshr(10)))
disp(sprintf(' Rental/leasing         %7.1f',wgshr(11)))
disp(sprintf(' Professional           %7.1f',wgshr(12)))
disp(sprintf(' Management             %7.1f',wgshr(13)))
disp(sprintf(' Administrative         %7.1f',wgshr(14)))
disp(sprintf(' Education              %7.1f',wgshr(15)))
disp(sprintf(' Health                 %7.1f',wgshr(16)))
disp(sprintf(' Arts                   %7.1f',wgshr(17)))
disp(sprintf(' Accommodation          %7.1f',wgshr(18)))
disp(sprintf(' Other services         %7.1f',wgshr(19)))
disp(sprintf(' Not in Pratt''s         %7.1f',nishr))
disp(' ')
disp(' Aggregates:')
disp(sprintf('   Unweighted           %7.1f',shr0))
disp(sprintf('   Equal-weighted*      %7.1f',shr1))
disp(sprintf('   Sales-weighted*      %7.1f',shr2)) 
disp('------------------------------------')
disp('* Pass-through weights from Pratt''s')

